Why does bin / mocha not work all my tests?

I have a node.js / express / mocha project. From my project root directory that I am doing

./node_modules/.bin/mocha --compilers coffee:coffee-script-redux/register test/**/*.coffee --reporter list

  1) UnitsController /units.json "before all" hook
  ․ CordBloodUnit should set attrs: 0ms
  ․ CordBloodUnit #getMatchCount should get the match count of alleles: 0ms
  ․ pg-adapter #runQuery should get results of the query: 7ms
  ․ pg-adapter #runQuery should get Cord Blood Units: 4ms

  4 passing (2s)
  1 failing

  1) UnitsController /units.json "before all" hook:
     Error: timeout of 2000ms exceeded
    at Object.<anonymous> (/Users/pguruprasad/Projects/jeevan-js/node_modules/mocha/lib/runnable.js:175:14)
    at Timer.list.ontimeout (timers.js:101:19)

I see that all tests are running. But when I want to execute a long command in a script to execute, mocha runs only two tests and ignores the remaining ones. What could be wrong here?

➜  ~jjs git:(master) ✗ touch test1
➜  ~jjs git:(master) ✗ echo "./node_modules/.bin/mocha --compilers coffee:coffee-script-redux/register test/**/*.coffee --reporter list" >> test1
➜  ~jjs git:(master) ✗ cat test1
./node_modules/.bin/mocha --compilers coffee:coffee-script-redux/register test/**/*.coffee --reporter list
➜  ~jjs git:(master) ✗ chmod +x test1
➜  ~jjs git:(master) ✗ ./test1       

  ․ CordBloodUnit should set attrs: 0ms
  ․ CordBloodUnit #getMatchCount should get the match count of alleles: 0ms

  2 passing (2ms)
+3
source share
4 answers

Your problem is probably related to the path or environment variables your script is working with. Perhaps it launches global mocha instead of the mocha installed in your project, or it may have a different version of cwd.

I highly recommend adding the following to the scripting section of your package.json:

"scripts": {
    "test": "mocha --compilers coffee:coffee-script-redux/register test/**/*.coffee --reporter list",
  }

npm test. , npm , . , , , , -phantomjs "npm" node.js?. , Windows, Unix OS X.

+1

./node_modules/.bin/_mocha

0

, . coffee, .js. , , - : my_file_test.coffee. _test.coffee.

0

This happened to me, and the problem was that I had a block describe()without calls it(). Hope someone helps!

-1
source

All Articles