Mocha: Mocha reports 'No test files found' since mocha 6 (with ts-node)

Created on 25 Feb 2019  路  6Comments  路  Source: mochajs/mocha

Prerequisites

  • [X] Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • [X] Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • [X] 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • [X] Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you _not_ install Mocha globally.

Description

Since the upgrade to mocha 6 my tests no longer work. I ensures that it wasn't any other package update that caused this issue by keeping all my dependencies identical except mocha 5 / 6.

The configuration I use in `mocha.opts' is as follows:

--recursive
--require ts-node/register
--exit
test/**/*.ts

The error I get from running ./node_modules/.bin/mocha is 'No test files found

I realize that this issue might not be caused by mocha, but it seemed like a good first place to ask. Could something have changed that would cause something like ts-node to fail?

unconfirmed-bug

Most helpful comment

It's a 6.0 bug (#3763), fix is in process.
Workaround until then by repeating the spec glob:

"package.json":

{
  "scripts": {
    "test": "mocha 'test/**/*.ts'"
  }
}

All 6 comments

It's a 6.0 bug (#3763), fix is in process.
Workaround until then by repeating the spec glob:

"package.json":

{
  "scripts": {
    "test": "mocha 'test/**/*.ts'"
  }
}

Thanks for the quick response. Super appreciate this project!

I have a similar kind of problem. Please take a look at the following link.
https://stackoverflow.com/questions/64173341/unable-to-find-server-js-file-while-testing-with-mocha

This still exists today unfortunately.

It doesn't, I use this configuration and it's perfect:

  "mocha": {
    "require": [
      "ts-node/register",
    ],
    "recursive": true,
    "extension": [
      "ts",
      "js",
      "tsx"
    ],
  }

Oh, I'm sorry. I didn't mean to necrobump this, especially since it's not the right issue I was looking at 馃槩

Thanks for replying and adding your example!

Was this page helpful?
0 / 5 - 0 ratings