Skip to content

cli option --require trace-something causes bad option-error #3761

@nknapp

Description

@nknapp

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 avoiding the use of globally installed Mocha.

Description

When executing mocha with the option --require trace-something, the error bad-option --trace-something is output. In my case. it is trace-and-clarify-if-possible, but it is reproducible with other package names.

This happens in [email protected] and [email protected], but not in [email protected], and only if the required package-name starts with "trace-"

Steps to Reproduce

# Setup dependency with empty index.js-file
mkdir trace-dependency
cd trace-dependency/
npm init -y
touch index.js
cd ..

# Setup project and add dependency
mkdir test-project
cd test-project
npm init -y
npm install ../trace-dependency
mkdir test
touch test/dash-spec.js

Then install mocha and run the tests:

npm install [email protected]
npx mocha --require trace-dependency
# Error "bad option --trace-dependency"

npm install [email protected]
npx mocha --require trace-dependency
# Error "bad option --trace-dependency"

npm install [email protected]
npx mocha --require trace-dependency
# No error, "0 passing"

Expected behavior: [What you expect to happen]

I would have expected the same result for each mocha-version, i.e. the output "0 passing".

Actual behavior: [What actually happens]

Reproduces how often: [What percentage of the time does it reproduce?]

100%

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version: 6.0.0, 6.0.1
  • The output of node --version: v10.15.1
  • The version and architecture of your operating system: Xubuntu 18.04
  • Your shell (bash, zsh, PowerShell, cmd, etc.): bash
  • Any other third party Mocha related modules (with versions): none
  • The code transpiler being used: none

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: node.jscommand-line-or-Node.js-specifictype: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions