Skip to content

Commit 6ee62b5

Browse files
committed
test: move source-map assert regression into output snapshots
Fold the .mjs and .cjs --enable-source-maps cases from the standalone test-assert-ok-source-maps.js into the existing snapshot output test, following the setup in test-node-output-sourcemaps.mjs as requested in review. The fixtures live under test/fixtures/source-map/output/ with a `// Flags: --enable-source-maps` directive and assert AssertionError output via snapshots instead of bespoke spawnSync assertions. Refs: nodejs#63169 Signed-off-by: June Kim <[email protected]>
1 parent 8d14a76 commit 6ee62b5

8 files changed

Lines changed: 61 additions & 69 deletions

‎test/fixtures/source-map/assert-no-source-map.cjs‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎test/fixtures/source-map/assert-no-source-map.mjs‎

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Flags: --enable-source-maps
2+
3+
import '../../../common/index.mjs';
4+
import { strict as assert } from 'node:assert';
5+
6+
// Regression test for https://github.com/nodejs/node/issues/63169
7+
// Under --enable-source-maps with no source map for this file, a failing
8+
// assert(value) must throw AssertionError, not TypeError ERR_INVALID_ARG_TYPE.
9+
assert(false);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node:internal/modules/run_main:<line>
2+
triggerUncaughtException(
3+
^
4+
5+
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
6+
7+
assert(false)
8+
9+
at file://<project-root>/test/fixtures/source-map/output/source_map_assert_no_source_map.mjs:9:1
10+
at <node-internal-frames>
11+
at <node-internal-frames> {
12+
generatedMessage: true,
13+
code: 'ERR_ASSERTION',
14+
actual: false,
15+
expected: true,
16+
operator: '==',
17+
diff: 'simple'
18+
}
19+
20+
Node.js <node-version>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Flags: --enable-source-maps
2+
3+
'use strict';
4+
require('../../../common');
5+
const assert = require('node:assert');
6+
7+
// Regression test for https://github.com/nodejs/node/issues/63169
8+
// Under --enable-source-maps with no source map for this file, a failing
9+
// assert.ok(value) must throw AssertionError, not TypeError ERR_INVALID_ARG_TYPE.
10+
assert.ok(false);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node:internal/assert/utils:<line>
2+
throw error;
3+
^
4+
5+
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
6+
7+
assert.ok(false)
8+
9+
at Object.<anonymous> (<project-root>/test/fixtures/source-map/output/source_map_assert_ok_no_source_map.cjs:10:8)
10+
at <node-internal-frames>
11+
at <node-internal-frames> {
12+
generatedMessage: true,
13+
code: 'ERR_ASSERTION',
14+
actual: false,
15+
expected: true,
16+
operator: '==',
17+
diff: 'simple'
18+
}
19+
20+
Node.js <node-version>

‎test/parallel/test-assert-ok-source-maps.js‎

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎test/parallel/test-node-output-sourcemaps.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { describe, it } from 'node:test';
55

66
describe('sourcemaps output', { concurrency: !process.env.TEST_PARALLEL }, () => {
77
const tests = [
8+
{ name: 'source-map/output/source_map_assert_no_source_map.mjs' },
9+
{ name: 'source-map/output/source_map_assert_ok_no_source_map.cjs' },
810
{ name: 'source-map/output/source_map_disabled_by_api.js' },
911
{ name: 'source-map/output/source_map_disabled_by_process_api.js' },
1012
{ name: 'source-map/output/source_map_enabled_by_api.js' },

0 commit comments

Comments
 (0)