-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
mocha failed and shows ERROR: null #5048
Comments
I'm having the same issue with following configuration: extensions:
- "ts"
project: "./tsconfig.json"
spec:
- "./**/*.test.ts"
require:
- "ts-node/register"
- "tsconfig-paths/register"
reporter: "dot"
node-option:
- "experimental-specifier-resolution=node"
- "loader=ts-node/esm" |
I'm also experiencing this issue. I'm using node v21.4.0 and ts-node. This command fails with "Error: null":
|
I found that this happens with recent versions of node. For example, worked find in 18.17 but is broken in 18.19 |
My problem is actually |
Alternatively, see TypeStrong/ts-node#1007 (comment) |
I resolved this problem by changing "ts-node/esm" to "tsx/esm": "node-option": [ |
Where do you set this `node_option`?
…________________________________
From: Rustam108 ***@***.***>
Sent: Wednesday, 3 January 2024 17:54
To: mochajs/mocha
Cc: Tomasz Pluskiewicz; Manual
Subject: Re: [mochajs/mocha] mocha failed and shows ERROR: null (Issue #5048)
I resolved this problem by: changing "esm" to "tsx/esm":
"node-option": [
"experimental-specifier-resolution=node",
"import=tsx/esm",
"trace-uncaught"
],
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
The Mocha config file, such as See also:
This issue seems to have turned into a general Q&A, so I'm going to close it out as resolved. Glad things seem to have been figured out! If there's still a bug you'd like to report (echoing ...and also, please, use |
For whom it may help, I've had this issue because my tsconfig.json had Still, the |
I'm using ts-mocha and put mistaken code like this:
this.logger?.error(e)
ts-mocha is failed, and after debugging code of mocha I've detected stupid reaction like this
(node:13116) ExperimentalWarning:
--experimental-loadermay be removed in the future; instead use
register(): --import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));' (Use
node --trace-warnings ...` to show where the warning was created)mocha inspect [spec..]
Run tests with Mocha
Rules & Behavior
--allow-uncaught Allow uncaught errors to propagate [boolean]
-A, --async-only Require all tests to use a callback (async) or
return a Promise [boolean]
-b, --bail Abort ("bail") after first test failure [boolean]
--check-leaks Check for global variable leaks [boolean]
--delay Delay initial execution of root suite [boolean]
--dry-run Report tests without executing them [boolean]
--exit Force Mocha to quit after tests complete [boolean]
--fail-zero Fail test run if no test(s) encountered [boolean]
--forbid-only Fail if exclusive test(s) encountered [boolean]
--forbid-pending Fail if pending test(s) encountered [boolean]
--global, --globals List of allowed global variables [array]
-j, --jobs Number of concurrent jobs for --parallel; use 1 to
run in serial
[number] [default: (number of CPU cores - 1)]
-p, --parallel Run tests in parallel [boolean]
--retries Retry failed tests this many times [number]
-s, --slow Specify "slow" test threshold (in milliseconds)
[string] [default: 75]
-t, --timeout, --timeouts Specify test timeout threshold (in milliseconds)
[string] [default: 2000]
-u, --ui Specify user interface [string] [default: "bdd"]
Reporting & Output
-c, --color, --colors Force-enable color output [boolean]
--diff Show diff on failure
[boolean] [default: true]
--full-trace Display full stack traces [boolean]
--inline-diffs Display actual/expected differences
inline within each string [boolean]
-R, --reporter Specify reporter to use
[string] [default: "spec"]
-O, --reporter-option, Reporter-specific options
--reporter-options (<k=v,[k1=v1,..]>) [array]
Configuration
--config Path to config file [string] [default: (nearest rc file)]
-n, --node-option Node or V8 option (no leading "--") [array]
--package Path to package.json for config [string]
File Handling
--extension File extension(s) to load
[array] [default: ["js","cjs","mjs"]]
--file Specify file(s) to be loaded prior to root suite
execution [array] [default: (none)]
--ignore, --exclude Ignore file(s) or glob pattern(s)
[array] [default: (none)]
--recursive Look for tests in subdirectories [boolean]
-r, --require Require module [array] [default: (none)]
-S, --sort Sort test files [boolean]
-w, --watch Watch files in the current working directory for
changes [boolean]
--watch-files List of paths or globs to watch [array]
--watch-ignore List of paths or globs to exclude from watching
[array] [default: ["node_modules",".git"]]
Test Filters
-f, --fgrep Only run tests containing this string [string]
-g, --grep Only run tests matching this string or regexp [string]
-i, --invert Inverts --grep and --fgrep matches [boolean]
Positional Arguments
spec One or more files, directories, or globs to test
[array] [default: ["test"]]
Other Options
-h, --help Show usage information & exit [boolean]
-V, --version Show version number & exit [boolean]
--list-interfaces List built-in user interfaces & exit [boolean]
--list-reporters List built-in reporters & exit [boolean]
× ERROR: null
`
The text was updated successfully, but these errors were encountered: