Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error while importing chai-spies #45

Closed
jalalat opened this issue Oct 31, 2016 · 15 comments
Closed

error while importing chai-spies #45

jalalat opened this issue Oct 31, 2016 · 15 comments

Comments

@jalalat
Copy link

jalalat commented Oct 31, 2016

I got the following error: [ts] Module ''chai-spies'' resolves to a non-module entity and cannot be imported using this construct.

chai.spy() - [ts] Property 'spy' does not exist on type 'ChaiStatic'.

Please help. Thanks.

@dotansimha
Copy link
Collaborator

@jalalat is that just a warning from the TypeScript compiler, or something actually don't work?

@jalalat
Copy link
Author

jalalat commented Nov 2, 2016

Hi @dotansimha I found out next day that it is compiling and working fine. So definitely an issue with typings. I installed everything correctly. I am able to proceed but it bothers me to see lot of TypeScript errors in my testing scripts.

i resolved the first error using:
import chai = require('chai');
import spies = require('chai-spies');

Second and many others similar TS errors I am not able to find the solution. Is there any fix for that. I searched a lot on internet and i have got the right typings. As a beginner i like when i type . i can see the functions/variables available.

Not an issue if there is no fix. Really appreciate your help and time that you got back to me.

@dotansimha
Copy link
Collaborator

@jalalat usually it's just typings issue.
do you use the latest version of the boilerplate?

Also, which IDE do you use?

@jalalat
Copy link
Author

jalalat commented Nov 3, 2016

Hi @dotansimha there are more typing errors with new version of boilerplate with describe, beforeEach, it etc. My initial thoughts were may be these errors are there due to not importing @types in typings.d.ts so i inserted these 2 lines in typings.d.ts:

/// <reference types="@types/mocha" />
/// <reference types="@types/chai" />

Still getting all errors related to describe, beforeEach, it etc. I noticed another Typings error with latest boilerplate. If you go deep upto 3 levels it complains example: @angular/core/testing, @angular/platform-browser-dynamic/testing

@jalalat
Copy link
Author

jalalat commented Nov 3, 2016

My project files are as below (not based on latest boilerplate):

typings.json

{
  "name": "BakBak",
  "version": false,
  "dependencies": {
    "chai-spies": "registry:npm/chai-spies#0.7.1+20160614064916"
  },
  "globalDependencies": {
    "chai": "registry:dt/chai#3.4.0+20160601211834",
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
    "meteor": "github:meteor-typings/meteor/1.3#955b89a4e2af892d1736bc570b490a97e860d5b7",
    "mocha": "registry:dt/mocha#2.2.5+20160619032855"
  }
}

index.d.ts:

/// <reference path="globals/angular2-compilers/index.d.ts" />
/// <reference path="globals/es6-shim/index.d.ts" />
/// <reference path="globals/meteor/index.d.ts" />
/// <reference path="globals/mocha/index.d.ts" />
/// <reference path="globals/chai/index.d.ts" />
/// <reference path="modules/chai-spies/index.d.ts" />
declare let SimpleSchema: any;
declare let ValidatedMethod: any;
declare let DDPRateLimiter: any;
declare let _: any;
declare let Roles: any;

declare module 'meteor/tmeasday:publish-counts' {
    import { Mongo } from 'meteor/mongo';
    interface CountsObject {
        get(publicationName: string): number;
        publish(context: any, publicationName: string, cursor: Mongo.Cursor<any>, 
            options?: any): number;
    }
    export const Counts: CountsObject;
}

package.json:

{
  "name": "bakbak24",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "test": "meteor test --driver-package practicalmeteor:mocha",
    "test:ci": "meteor test --once --driver-package dispatch:mocha-phantomjs"
  },
  "devDependencies": {
    "@types/chai": "^3.4.33",
    "@types/mocha": "^2.2.32",
    "chai": "3.5.0",
    "chai-spies": "^0.7.1",
    "husky": "^0.11.8",
    "minimist": "^1.2.0",
    "node-localstorage": "^1.3.0",
    "parse-diff": "0.4.0",
    "typings": "^1.3.3"
  },
  "dependencies": {
    "@angular/common": "^2.1.0",
    "@angular/compiler": "^2.1.0",
    "@angular/core": "^2.1.0",
    "@angular/forms": "^2.1.0",
    "@angular/http": "^2.1.0",
    "@angular/material": "^2.0.0-alpha.9-3",
    "@angular/platform-browser": "^2.1.0",
    "@angular/platform-browser-dynamic": "^2.1.0",
    "@angular/router": "^3.1.0",
    "@angular2-material/button": "2.0.0-alpha.8-2",
    "@angular2-material/button-toggle": "^2.0.0-alpha.8-2",
    "@angular2-material/card": "2.0.0-alpha.8-2",
    "@angular2-material/checkbox": "2.0.0-alpha.8-2",
    "@angular2-material/core": "2.0.0-alpha.8-2",
    "@angular2-material/grid-list": "^2.0.0-alpha.8-2",
    "@angular2-material/icon": "2.0.0-alpha.8-2",
    "@angular2-material/input": "2.0.0-alpha.8-2",
    "@angular2-material/list": "2.0.0-alpha.8-2",
    "@angular2-material/menu": "2.0.0-alpha.8-2",
    "@angular2-material/radio": "^2.0.0-alpha.8-2",
    "@angular2-material/tabs": "2.0.0-alpha.8-2",
    "@angular2-material/toolbar": "^2.0.0-alpha.8-2",
    "angular2-meteor": "^0.7.0-beta.1",
    "angular2-meteor-accounts-ui": "^0.6.1",
    "angular2-meteor-polyfills": "0.1.1",
    "angular2-meteor-tests-polyfills": "0.0.2",
    "angular2-moment": "^0.8.2",
    "es6-shim": "0.35.1",
    "meteor-node-stubs": "0.2.3",
    "meteor-rxjs": "^0.3.0",
    "meteor-typings": "1.3.1",
    "moment": "^2.14.1",
    "reflect-metadata": "0.1.3",
    "rxjs": "5.0.0-beta.6",
    "spawn-sync": "^1.0.15",
    "zone.js": "^0.6.25"
  }
}

@dotansimha
Copy link
Collaborator

@jalalat I fixed all types issues in f3eded9 and 5d22b3d

@jalalat
Copy link
Author

jalalat commented Nov 8, 2016

Still the same errors. Sorry @dotansimha .

@dotansimha
Copy link
Collaborator

@jalalat , do you use the latest boilerplate, and then run npm install, and npm run test in order to run Chai?

@jalalat
Copy link
Author

jalalat commented Nov 9, 2016

@dotansimha yes same steps. As you know these are not code errors rather Typings errors in code editors (Visual studio code and Sublime Text).

I will try a new laptop in the evening and will let you know.

@dotansimha
Copy link
Collaborator

With latest WebStorm - everything works great and detected correctly, without any lint errors.

@jalalat
Copy link
Author

jalalat commented Nov 9, 2016

you are right. It works on WebStorm. I got a wonderful opportunity to try various different editors like Sublime, Visual code, Atom and now WebStorm :)

@jalalat
Copy link
Author

jalalat commented Nov 9, 2016

However i could not make all chai-spies methods to work in this boilerplate like:
var array = [ 1, 2, 3 ];
chai.spy.on(array, 'push');

@dotansimha
Copy link
Collaborator

Can you share the full code you are trying to run with the Spy? maybe I missed some methods in the Typings.

@jalalat
Copy link
Author

jalalat commented Nov 10, 2016

Hi @dotansimha, thanks a lot for your help. Very much appreciate your time. I was just trying chai-spies before i could start using it in my code fully. I was testing the examples provided here: https://github.com/chaijs/chai-spies

@dotansimha
Copy link
Collaborator

@jalalat please refer to typings.d.ts file and check it all the methods that you use on the spy object are defined there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants