The Wayback Machine - https://web.archive.org/web/20200707190012/https://github.com/mochajs/mocha/issues/4047
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

Unhandled exception of`--file` option with non-existed file #4047

Open
outsideris opened this issue Oct 5, 2019 · 3 comments
Open

Unhandled exception of`--file` option with non-existed file #4047

outsideris opened this issue Oct 5, 2019 · 3 comments

Comments

@outsideris
Copy link
Member

@outsideris outsideris commented Oct 5, 2019

If specify non-existed file with --file option, mocha throw expection.

./bin/mocha --file non-existed
/Users/mocha/node_modules/yargs/yargs.js:1163
      else throw err
           ^

Error: Cannot find module '/Users/mocha/non-existed'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at /Users/mocha/lib/mocha.js:309:36
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/Users/mocha/lib/mocha.js:306:14)
    at Mocha.run (/Users/mocha/lib/mocha.js:784:10)
    at Object.exports.singleRun (/Users/mocha/lib/cli/run-helpers.js:108:16)
    at exports.runMocha (/Users/mocha/lib/cli/run-helpers.js:143:13)
    at Object.exports.handler.argv [as handler] (/Users/mocha/lib/cli/run.js:305:3)
    at Object.runCommand (/Users/mocha/node_modules/yargs/lib/command.js:242:26)
    at Object.parseArgs [as _parseArgs] (/Users/mocha/node_modules/yargs/yargs.js:1104:24)
    at Object.parse (/Users/mocha/node_modules/yargs/yargs.js:566:25)
    at Object.exports.main (/Users/mocha/lib/cli/cli.js:68:6)
    at Object.<anonymous> (/Users/mocha/bin/mocha:131:29)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

It should be handled like --require.

./bin/mocha --require non-existed
mocha inspect [spec..]

Run tests with Mocha

Rules & Behavior
  --allow-uncaught           Allow uncaught errors to propagate        [boolean]

...

  --list-interfaces  List built-in user interfaces & exit              [boolean]
  --list-reporters   List built-in reporters & exit                    [boolean]

✖ ERROR: Cannot find module 'non-existed'
@ntedgi
Copy link

@ntedgi ntedgi commented Jan 26, 2020

i would like to give it a try

@LeonardoSalvucci
Copy link

@LeonardoSalvucci LeonardoSalvucci commented Mar 25, 2020

Captura de Pantalla 2020-03-25 a la(s) 13 22 26

I just made this fix, it'll verify if file exists and if not will remove from args and show a warning like the image but continue to process the other files. Do you think that is resolved like this? Must i send a PR? [It's my first collaboration :) ] Thanks!
@shobhu98
Copy link

@shobhu98 shobhu98 commented May 8, 2020

I want to work on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.