Skip to content

Regression: Mocha ignores files after -- (end of CLI options) #3899

@demurgos

Description

@demurgos

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

During the Mocha@6 rewrite of the CLI, a regression occurred: Mocha now ignores the test files supplied after --. Support for -- is required to allow consumers to safely generate the command line arguments and avoid conflicts between test files and CLI options.

Steps to Reproduce

In a directory with test.spec.js, run:

mocha -- test.spec.js

Expected behavior: Mocha executes the tests in test.spec.js.

Actual behavior: Mocha immediately returns with the following error:

Error: No test files found: "test"

Reproduces how often: All the time

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version: 6.1.4
  • The output of node --version: 12.1.0
  • Your operating system
    • name and version: Linux 5.0.9
    • architecture (32 or 64-bit): 64-bit
  • Your shell (e.g., bash, zsh, PowerShell, cmd): Bash
  • Your browser and version (if running browser tests): N/A
  • Any third-party Mocha-related modules (and their versions): N/A
  • Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): N/A

Additional Information

In Mocha@5, the command mocha -- test.spec.js works. It fails since the rewrite from #3556.

Metadata

Metadata

Assignees

Labels

area: node.jscommand-line-or-Node.js-specificstatus: needs upstream fixdefect within Mocha's dependency treetype: buga defect, confirmed by a maintainer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions