chai icon indicating copy to clipboard operation
chai copied to clipboard

0 passing - Why doesn't it say 5 passing?

Open sancarn opened this issue 5 years ago • 0 comments

Original: https://stackoverflow.com/questions/58384761/node-mocha-0-passing


I've seen numerous posts on stack overflow about this issue, however none of the solutions that I have read thus far, have worked in my specific case. I'm generally quite confused as to why this might be happening.

Things I've already tested:

  • Adding test scripts to test/ folder
  • Adding test script folder path to test command
  • Adding test script file path to test command

The weirdest thing of all is that Moca is definitely finding the files, and executing them, and running the tests. In fact if a test fails, Moca will throw an error e.g.

AssertionError: expected 1 to equal 0
    at Object.<anonymous> (/Users/Sancarn/Documents/Programming/Github/node-macUIAutomation/test/TSEnum.test.js:33:14)

So the tests are definitely running, and the tests are definitely passing. As you can see from the TSEnum.test.js file below I should have 5 passes. However when run it says 0 passed:

npm test

> [email protected] test /Users/Sancarn/Documents/Programming/Github/node-macUIAutomation
> mocha ./test/*.test.js

|CoolSuite|


  0 passing (0ms)

Why does it say 0 passed? How can I fix this? Any ideas?

My project folder structure:

package.json
lib/
|- TSEnum.js
test/
|- TSEnum.test.js
...

Package.json:

{
  ...
  "scripts": {
    "test": "./node_modules/.bin/mocha ./test/*.test.js"
  },
  ...
}

In TSEnum.test.js:

...js
const assert = require('chai').assert;
console.log("|"+tse.suite+"|")   // returns "|CoolSuite|"
assert(tse.suite == "CoolSuite","Suite no initialised");
assert(1==1,"zomg")
assert(1==1,"zomg")
assert(1==1,"zomg")
assert(1==1,"zomg")

So does anyone have any idea why it says 0 passed? Everything else seems to work fine except this issue. It's not a major issue but is very confusing...

Thanks

sancarn avatar Oct 16 '19 19:10 sancarn