Report invalid `--require` directly instead of via UnhandledPromiseRejectionWarning
@Krinkle is already working on this.
Since Apr 24, 2022.
Assessment
This issue has not been assessed yet.
Description
- QUnit version: 2.18.2
- Which environment are you using?: Node.js
- How are you running QUnit?: QUnit CLI
We have a test case displays helpful error when failing to require a file in test/cli/cli-main.js which. The assertion currently ensures that the output "includes" the important subset, which is Error: Cannot find module 'does-not-exist-at-all'.
However, when running it directly (in prep for https://github.com/qunitjs/qunit/issues/1684) I noticed it gets there in quite an unsual manner:
(node:4519) UnhandledPromiseRejectionWarning: Error: Cannot find module 'does-not-exist-at-all'
Require stack:
- /qunit/src/cli/require-from-cwd.js
- /qunit/src/cli/run.js
- /qunit/bin/qunit.js
at internal
at bin/qunit
at internal
at bin/qunit
at internal
(node:4519) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4519) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This happens because /src/cli/run.js currently handles options.requires before setting up options.reporter and process.on('unhandledRejection'). I suggest we swap this around.
- Dominant language
- JavaScript
- Stars
- 4k
- Forks
- 773
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from qunitjs/qunit
-
Category: Docs Type: Enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Component: Core Type: Task
-
Category: Docs Type: Enhancement
-
Component: Core Type: Enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Component: Dump Component: HTML Reporter Type: Bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Similar issues
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100