-
Notifications
You must be signed in to change notification settings - Fork 30k
/
test-require-module-cycle-esm-esm-cjs-esm.js
82 lines (76 loc) Β· 1.79 KB
/
test-require-module-cycle-esm-esm-cjs-esm.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'use strict';
require('../common');
const { spawnSyncAndAssert } = require('../common/child_process');
const fixtures = require('../common/fixtures');
const assert = require('assert');
// a.mjs -> b.mjs -> c.mjs -> d.mjs -> c.mjs
{
spawnSyncAndAssert(
process.execPath,
[
'--experimental-require-module',
fixtures.path('es-modules/esm-esm-cjs-esm-cycle/a.mjs'),
],
{
signal: null,
status: 0,
trim: true,
stdout(output) {
assert.match(output, /Start c/);
assert.match(output, /dynamic import b\.mjs failed.*ERR_REQUIRE_CYCLE_MODULE/);
assert.match(output, /dynamic import d\.mjs failed.*ERR_REQUIRE_CYCLE_MODULE/);
}
}
);
}
// b.mjs -> c.mjs -> d.mjs -> c.mjs
{
spawnSyncAndAssert(
process.execPath,
[
'--experimental-require-module',
fixtures.path('es-modules/esm-esm-cjs-esm-cycle/b.mjs'),
],
{
signal: null,
status: 1,
trim: true,
stdout: /Start c/,
stderr: /Cannot import Module \.\/c\.mjs in a cycle\. \(from .*d\.mjs\)/,
}
);
}
// c.mjs -> d.mjs -> c.mjs
{
spawnSyncAndAssert(
process.execPath,
[
'--experimental-require-module',
fixtures.path('es-modules/esm-esm-cjs-esm-cycle/c.mjs'),
],
{
signal: null,
status: 1,
trim: true,
stdout: /Start c/,
stderr: /Cannot import Module \.\/c\.mjs in a cycle\. \(from .*d\.mjs\)/,
}
);
}
// d.mjs -> c.mjs -> d.mjs
{
spawnSyncAndAssert(
process.execPath,
[
'--experimental-require-module',
fixtures.path('es-modules/esm-esm-cjs-esm-cycle/d.mjs'),
],
{
signal: null,
status: 1,
trim: true,
stdout: /Start c/,
stderr: /Cannot require\(\) ES Module .*d\.mjs in a cycle\. \(from .*c\.mjs\)/,
}
);
}