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 does not work #1160

Closed
ORESoftware opened this issue May 17, 2016 · 9 comments
Closed

npm test does not work #1160

ORESoftware opened this issue May 17, 2016 · 9 comments
Labels

Comments

@ORESoftware
Copy link
Contributor

ORESoftware commented May 17, 2016

I am working on adding a test to the test suite

but when I run "npm test" I get

"Error: Cannot find module 'lodash/rest'"

e.g.:

Alexanders-MacBook-Pro:async Olegzandr$ sudo npm test

> async@2.0.0-rc.5 test /Users/Olegzandr/WebstormProjects/async
> npm run-script lint && npm run mocha-node-test


> async@2.0.0-rc.5 lint /Users/Olegzandr/WebstormProjects/async
> jshint lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/ karma.conf.js && jscs lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/ karma.conf.js

No code style errors found.

> async@2.0.0-rc.5 mocha-node-test /Users/Olegzandr/WebstormProjects/async
> mocha mocha_test/ --compilers js:babel-core/register

module.js:327
    throw err;
    ^

Error: Cannot find module 'lodash/rest'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (applyEach.js:3:1)
    at Module._compile (module.js:397:26)
    at loader (/Users/Olegzandr/WebstormProjects/async/node_modules/babel-register/lib/node.js:158:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/Olegzandr/WebstormProjects/async/node_modules/babel-register/lib/node.js:168:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (applyEach.js:3:1)
    at Module._compile (module.js:397:26)
    at loader (/Users/Olegzandr/WebstormProjects/async/node_modules/babel-register/lib/node.js:158:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/Olegzandr/WebstormProjects/async/node_modules/babel-register/lib/node.js:168:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (index.js:10:1)
    at Module._compile (module.js:397:26)
    at loader (/Users/Olegzandr/WebstormProjects/async/node_modules/babel-register/lib/node.js:158:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/Olegzandr/WebstormProjects/async/node_modules/babel-register/lib/node.js:168:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (apply.js:1:13)
    at Module._compile (module.js:397:26)
    at loader (/Users/Olegzandr/WebstormProjects/async/node_modules/babel-register/lib/node.js:158:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/Olegzandr/WebstormProjects/async/node_modules/babel-register/lib/node.js:168:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at /Users/Olegzandr/WebstormProjects/async/node_modules/mocha/lib/mocha.js:219:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/Olegzandr/WebstormProjects/async/node_modules/mocha/lib/mocha.js:216:14)
    at Mocha.run (/Users/Olegzandr/WebstormProjects/async/node_modules/mocha/lib/mocha.js:468:10)
    at Object.<anonymous> (/Users/Olegzandr/WebstormProjects/async/node_modules/mocha/bin/_mocha:403:18)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:429:10)
    at startup (node.js:139:18)
    at node.js:999:3

npm ERR! Darwin 15.4.0
npm ERR! argv "/Users/Olegzandr/.nvm/versions/node/v5.4.1/bin/node" "/Users/Olegzandr/.nvm/versions/node/v5.4.1/bin/npm" "run" "mocha-node-test"
npm ERR! node v5.4.1
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! async@2.0.0-rc.5 mocha-node-test: `mocha mocha_test/ --compilers js:babel-core/register`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the async@2.0.0-rc.5 mocha-node-test script 'mocha mocha_test/ --compilers js:babel-core/register'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the async package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     mocha mocha_test/ --compilers js:babel-core/register
npm ERR! You can get their info via:
npm ERR!     npm owner ls async
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Olegzandr/WebstormProjects/async/npm-debug.log
npm ERR! Test failed.  See above for more details.
Alexanders-MacBook-Pro:async Olegzandr$ 

definitely seems to be a problem, I even tried transpiling separately on my own with babel-cli and running separately with mocha without the --compilers arg and I get the same error - I am not that familiar with ES2015 import statements so not sure how to figure out what's wrong.

@megawac
Copy link
Collaborator

megawac commented May 17, 2016

Can you try installing lodash again (npm install lodash) and if that doesn't work reinstall your node modules? npm test works locally for me after a fresh install.

@megawac
Copy link
Collaborator

megawac commented May 17, 2016

Also you should avoid using sudo with npm. If you're having permission issues you should chown your $HOME/.npm directory

@ORESoftware
Copy link
Contributor Author

for sure, let me give it a go thanks

@ORESoftware
Copy link
Contributor Author

I got it to work by reinstalling lodash

however, there is one test fail

  324 passing (12s)
  1 failing

  1) queue pause:

      Uncaught AssertionError: expected [ Array(12) ] to deeply equal [ Array(12) ]
      + expected - actual

@ORESoftware
Copy link
Contributor Author

ORESoftware commented May 18, 2016

the reason I was looking into your tests is because I am developing a new test runner (Suman) for Node that will go head-to-head with AVA

one of the pluses of Suman is that it can transpile Mocha tests to Suman tests, because the Suman API adheres closely to Mocha's API (whereas AVA adheres closer to Tape's).

I cloned the async repo and added a directory with Suman tests:
https://github.com/ORESoftware/async-suman

you will see that if you run your test suite with Mocha (npm test), it takes about 12 seconds for Mocha to run (more than 12 for the linting etc) and everything is run in a single process. I have to say your test suite is pretty clean, and there doesn't appear to be any crossover between tests.

But in any case, when running your test suite with Suman, it runs under 6 seconds, so it's a > 50% decrease in time. This may not be super important, but test isolation is a great feature, and it will basically force you to keep tests independent. Given that each test is run in a separate process, Suman has a lot of features/prescriptions to allow for code reuse and loading of asynchronous dependencies.

Suman is not quite ready, but if you're interested I can ping you again later. I would highly appreciate any feedback you have if you do take the time to try running Suman on this library.

To do so:

  1. clone the above repo
  2. npm install
  3. node ./node_modules/suman/index mocha_test-dest

it should run in less than half the time that Mocha takes

if you're interested in playing with suman further you can check out the Github repo for it my account, Suman has a cli of course, so the above command would normally be:

$ suman mocha_test-dest

thanks

@megawac
Copy link
Collaborator

megawac commented May 18, 2016

 324 passing (12s)
  1 failing
  1) queue pause:
      Uncaught AssertionError: expected [ Array(12) ] to deeply equal [ Array(12) ]
      + expected - actual

Ye thats a known issue (#1152) and I'm interested at least in an async test runner (was looking at AVA) (see #849). I'll play around with you're project whne I get a chance.

@megawac megawac reopened this May 18, 2016
@ORESoftware
Copy link
Contributor Author

ORESoftware commented May 18, 2016

Yep, the same test case failed for both Suman and Mocha.

Suman has big advantages over AVA, the Suman readme covers a lot of it. But you will have just witnessed one big advantage of Suman for projects currently using Mocha - you can convert pretty much automatically from Mocha to Suman. Suman runs each test file in a separate proc, and instead of running all hooks and test cases in series, it allows test cases and hooks to run in parallel, if so desired. Of your current test suites, everything was parallelizable except this file:

socket.io-socket.js

@megawac
Copy link
Collaborator

megawac commented May 18, 2016

@ORESoftware similar to AVA, suman is not going to be entirely appropriate for us to change to as we will want browser testing (done through karma). A future avenue you can perhaps explore is a) being able to convert mocha tests dynamically so suman can run on a mocha suite b) making a synchronous task runner (similar to tape) which can be run in the browser.

Regardless, I'm still going to play with your project and see how I like it.

@megawac megawac closed this as completed May 18, 2016
@ORESoftware
Copy link
Contributor Author

ORESoftware commented May 18, 2016

yeah, definitely understand WRT browser testing; supporting browser puts too much burden and constraints on Suman - I want Suman's competitive advantage to be that it is not have to support browser. Your idea to dynamically run mocha tests with suman as harness would be interesting - will explore, it is possible, not a bad idea at all.

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

No branches or pull requests

2 participants