Shamoon
Shamoon

Reputation: 43491

Mocha can't find my test files when using TypeScript

My test script in package.json is:

"test": "yarn seed && (nyc mocha --opts ./test/mocha.unit.opts)",

My mocha.unit.opts is:

--require ts-node/register
--require source-map-support/register
--require ./test/unit/helper.ts
--recursive
./test/unit/**/*.spec.ts
--exit

My folder structure looks like: enter image description here

There's no error, however. It shows the coverage (all 100% somehow) and exits with:

error Command failed with exit code 1.

When I run yarn test

What am I missing?

Upvotes: 2

Views: 2215

Answers (1)

Tomislav
Tomislav

Reputation: 752

I think that you didn't give enough info about the problem. There could be few problems and solutions:

  1. Check package.json (do you have everything installed properly)
  2. Check .spec.ts files, can they compile properly
  3. Can you try to run a test by test, maybe there is a problem in some of them
  4. Try to run mocha directly through terminal without mocha.units.optsfile

Upvotes: 3

Related Questions