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

"node-option" is mandatory in config file #4739

Closed
4 tasks done
cyrilverloop opened this issue Sep 4, 2021 · 2 comments
Closed
4 tasks done

"node-option" is mandatory in config file #4739

cyrilverloop opened this issue Sep 4, 2021 · 2 comments
Labels
invalid not something we need to work on, such as a non-reproducing issue or an external root cause

Comments

@cyrilverloop
Copy link

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • 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.
  • '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
  • 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

Hi,

Since Mocha 9.1.0, when i launch my tests, i have the error message : Error: No test files found.
Adding "node-option": [], in my .mocharc.json configuration file seems to solve the problem.
It seems that Mocha does not consider the path given in "recursive": ["./tests/**/*.js"] without this option.
I don't know if it is the expected behaviour from #4691.

Steps to Reproduce

user@host ~$ git clone https://github.com/cyrilverloop/mocha-node-option.git
user@host ~$ cd mocha-node-option
user@host mocha-node-option$ npm test
  • remove the option "node-option": [], in the .mocharc.json configuration file at the root of the project;
  • run the test to see the error message.
@juergba
Copy link
Contributor

juergba commented Sep 4, 2021

{
    "node-option": [],
    "recursive": ["./tests/**/*.js"],
    "ui": "tdd"
}

recursive is a boolean flag, not an array. Your .mocharc.json looks then as follows:

{
    "node-option": [],
    "spec": ["./test/**/*.js"],
    "ui": "tdd"
}

With or without node-option your test will run as expected.

@juergba juergba added invalid not something we need to work on, such as a non-reproducing issue or an external root cause and removed unconfirmed-bug labels Sep 4, 2021
@juergba juergba closed this as completed Sep 4, 2021
@cyrilverloop
Copy link
Author

@juergba changing "recursive" to "spec" was the answer i was looking for. Thanks !

I do not know why it worked before 9.1.0 nor why adding "node-option": [] makes it work now, but it does not matter to me.
I see that the "spec" default option is missing in .mocharc.json and .mocharc.jsonc. Should it be added ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid not something we need to work on, such as a non-reproducing issue or an external root cause
Projects
None yet
Development

No branches or pull requests

2 participants