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

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

Closed
4 tasks done
demurgos opened this issue Apr 30, 2019 · 2 comments · Fixed by #3986
Closed
4 tasks done

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

demurgos opened this issue Apr 30, 2019 · 2 comments · Fixed by #3986
Assignees
Labels
area: node.js command-line-or-Node.js-specific status: needs upstream fix defect within Mocha's dependency tree type: bug a defect, confirmed by a maintainer

Comments

@demurgos
Copy link
Contributor

demurgos commented Apr 30, 2019

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.

@demurgos demurgos changed the title Regression: Mocha ignore files after -- (end of CLI options) Regression: Mocha ignores files after -- (end of CLI options) Apr 30, 2019
@plroebuck plroebuck added type: bug a defect, confirmed by a maintainer area: node.js command-line-or-Node.js-specific and removed unconfirmed-bug labels May 2, 2019
@plroebuck
Copy link
Contributor

Not sure we ever "officially" said "--" was supported...

Assuming so, our support of it is "borken" in couple aspects:

  1. Added to wrong end of cmdline arguments (see mocha:cli:mocha exec _mocha)
  2. Incorrectly strips first dash from "--" and creates "-" option, assigning positional argument to it
    (see mocha:cli:run post-yargs)

@jimthedev
Copy link

Looks like v13.1.1 has the referenced issue fixed even if it hasn't been closed. There is a linked PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: node.js command-line-or-Node.js-specific status: needs upstream fix defect within Mocha's dependency tree type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants