Skip to content

No test files found even though one specified with --file #3941

@gabegorelick

Description

@gabegorelick

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

If mocha doesn't find any test files, it returns a No test files found error. This appears to happen even if --file is specified.

Steps to Reproduce

mocha --file foo.js --exclude '**/*.js'

Per the docs, "Files specified using --file are not affected" by --exclude, so this should work.

Expected behavior: foo.js is loaded

Actual behavior: No test files found error

Reproduces how often: 100%

Versions

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

Additional Information

Use case for this is to run only a given set of files and override any "default" files loaded via positional arguments. For example, mocha --file test/foo.js --exclude '**/*.js' 'test/**/*.js'
would only run test/foo.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: 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