-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Closed
Labels
assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.
Description
Version
21.1.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
const assert = require("assert");
assert.ok(0 === 2)
import assert from "assert"
assert.ok(0 === 2)
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
The CJS code throws this error:
➜ node file.js
node:assert:399
throw err;
^
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
assert.ok(0 === 2)
at Object.<anonymous> (/Users/nic/Documents/misc/node-assert-test/file.js:3:8)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
I would expect something similar for ESM
What do you see instead?
ESM throws this error:
➜ node file.mjs
node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
AssertionError [ERR_ASSERTION]: false == true
at file:///Users/nic/Documents/misc/node-assert-test/file.mjs:3:8
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:113:12) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
Without showing the assert.ok
call.
Additional information
No response
Metadata
Metadata
Assignees
Labels
assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.