Skip to content

Commit 00dfc8f

Browse files
committed
test: cover case with a longer stack
1 parent a67f4e7 commit 00dfc8f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function main() {
2+
func1(func2(func3()))
3+
}
4+
5+
function func1() {
6+
require('./app.js')
7+
}
8+
function func2() {}
9+
function func3() {}
10+
11+
main()

test/parallel/test-require-esm-with-no-experimental-require-module.mjs

+18
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,21 @@ test('correctly reports errors when an ESM module is required with --no-experime
2121
assert(result.stderr.toString().match(matchRegex));
2222
assert.strictEqual(result.stdout.toString(), '');
2323
});
24+
25+
test('correctly reports error for a longer stack trace', () => {
26+
// The following regex matches the error message that is expected to be thrown
27+
//
28+
// package-type-module/require-esm-error-annotation/longer-stack.cjs:6
29+
// require('./app.js')
30+
// ^
31+
32+
const matchRegex = /package-type-module\/require-esm-error-annotation\/longer-stack\.cjs:6[\r?\n]\s{2}require\('\.\/app\.js'\)[\r?\n]\s{2}\^/;
33+
const fixture = fixtures.path('es-modules/package-type-module/require-esm-error-annotation/longer-stack.cjs');
34+
const args = ['--no-experimental-require-module', fixture];
35+
36+
const result = spawnSync(process.execPath, args);
37+
38+
assert.strictEqual(result.status, 1);
39+
assert(result.stderr.toString().match(matchRegex));
40+
assert.strictEqual(result.stdout.toString(), '');
41+
});

0 commit comments

Comments
 (0)