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

npm test: TypeError: Cannot read property 'stats' of undefined #217

Closed
Lokua opened this issue Nov 15, 2015 · 9 comments
Closed

npm test: TypeError: Cannot read property 'stats' of undefined #217

Lokua opened this issue Nov 15, 2015 · 9 comments

Comments

@Lokua
Copy link

Lokua commented Nov 15, 2015

When I run ava test/**/*.test.js from cli, everything runs beautifully The same command under package.json > scripts > test, ran with npm test throws the error, though all the tests are still run and pass (I just don't get the "n tests passed" output due to the error afterward).

Here's the error output:

test » # etc etc, all passing ...
TypeError: Cannot read property 'stats' of undefined
    at d:\home\lnet\o-\node_modules\ava\cli.js:139:16
    at Array.map (native)
    at exit (d:\home\lnet\o-\node_modules\ava\cli.js:138:22)
From previous event:
    at Object.<anonymous> (d:\home\lnet\o-\node_modules\ava\cli.js:216:18)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:136:18)
    at node.js:972:3
npm ERR! Test failed.  See above for more details.
@jamestalmage
Copy link
Contributor

You probably have different versions installed locally and globally, run the following two commands.

$ ava test/**/*.test.js
$ ./node_modules/.bin/ava test/**/*.test.js

There is a way to fix this, but it is fairly controversial.

@Lokua
Copy link
Author

Lokua commented Nov 16, 2015

Both are version 0.4.2, and both of the above commands run successfully, however npm test still errors at the end - likewise if I use ./node_modules/.bin/ava test/**/*.test.js as the npm test script. An odd thing I just noticed is that npm test does pass every so often - about 1/4 runs, which is even more confusing.

@jamestalmage
Copy link
Contributor

Is the repo you are using this with open source? If so can you post a link?

@jamestalmage
Copy link
Contributor

@Lokua the fix for that issue is in. We now include a check for empty test files. It's odd that it is only happening in local installs and not global, but the next release should give you a clearer error at least.

@Lokua
Copy link
Author

Lokua commented Nov 16, 2015

I saw the empty files issue, I don't think this is the same (no empty *.test.js files, though there are non test files in the same folder). You can see my current test setup here (https://github.com/Lokua/o-/tree/postcss).

@jamestalmage
Copy link
Contributor

@Lokua
I had some initial problems with global on your repo, but got it working pretty easy.

Try the following in your project directory

$ npm i -g npm@latest
$ npm rm -g ava
$ npm i -g ava@latest
$ npm rm ava
$ npm i ava@latest

Try it both ways again and report back.

@Lokua
Copy link
Author

Lokua commented Nov 16, 2015

Same thing. Global and local ava cli calls work fine, only from npm test does the same command error. I'm on Windows 10 btw. Perhaps that or npm has something to do with it. I noticed that putting the ava call in a shell script and running that from npm test also produced the same error, so yeah, I'm beginning to think this isn't really an ava specific issue. In any case I'm totally fine running ava from cli, just thought it was worth bringing up.

> node -v
v5.0.0
> npm -v
3.3.6
> ava --version
0.4.2
> ./node_modules/.bin/ava --version
0.4.2

@jamestalmage
Copy link
Contributor

Confirmed. AVA 0.4.2, Windows 7, Node 5.0.0, NPM 3.3.6

Already fixed in master.

npm install -D sindresorhus/ava#78a6c56e
npm install -g sindresorhus/ava#78a6c56e

@Lokua
Copy link
Author

Lokua commented Nov 17, 2015

Awesomeness. Thank you.

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

3 participants