-
Notifications
You must be signed in to change notification settings - Fork 30k
/
test-require-module-errors.js
48 lines (44 loc) · 1.2 KB
/
test-require-module-errors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Flags: --experimental-require-module
'use strict';
require('../common');
const assert = require('assert');
const { spawnSyncAndExit } = require('../common/child_process');
const fixtures = require('../common/fixtures');
spawnSyncAndExit(process.execPath, [
'--experimental-require-module',
fixtures.path('es-modules/require-syntax-error.cjs'),
], {
status: 1,
signal: null,
stderr(output) {
assert.match(output, /var foo bar;/);
assert.match(output, /SyntaxError: Unexpected identifier 'bar'/);
return true;
},
});
spawnSyncAndExit(process.execPath, [
'--experimental-require-module',
fixtures.path('es-modules/require-reference-error.cjs'),
], {
status: 1,
signal: null,
trim: true,
stdout: 'executed',
stderr(output) {
assert.match(output, /module\.exports = { hello: 'world' };/);
assert.match(output, /ReferenceError: module is not defined/);
return true;
},
});
spawnSyncAndExit(process.execPath, [
'--experimental-require-module',
fixtures.path('es-modules/require-throw-error.cjs'),
], {
status: 1,
signal: null,
stderr(output) {
assert.match(output, /throw new Error\('test'\);/);
assert.match(output, /Error: test/);
return true;
},
});