-
Notifications
You must be signed in to change notification settings - Fork 122
/
esmodule.js
53 lines (46 loc) · 1.66 KB
/
esmodule.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
const semver = require('semver');
const tap = require('tap');
const { spawn, touchFile } = require('../utils');
tap.test('Supports ECMAScript modules with experimental-specifier-resolution', t => {
if (semver.satisfies(process.version, '<12.17')) return t.skip();
if (process.platform === 'win32') return t.skip('ESM support on windows is broken');
spawn('--experimental-specifier-resolution=node resolution.mjs', out => {
if (out.match(/touch message.js/)) {
touchFile('message.js');
return out2 => {
if (out2.match(/Restarting/)) {
t.match(out2, /\[INFO\] \d{2}:\d{2}:\d{2} Restarting/);
return { exit: t.end.bind(t) };
}
};
}
});
});
tap.test('Supports ECMAScript modules', t => {
if (process.platform === 'win32') return t.skip('ESM support on windows is broken');
spawn('ecma-script-modules.mjs', out => {
if (out.match(/touch message.mjs/)) {
touchFile('message.mjs');
return out2 => {
if (out2.match(/Restarting/)) {
t.match(out2, /\[INFO\] \d{2}:\d{2}:\d{2} Restarting/);
return { exit: t.end.bind(t) };
}
};
}
});
});
tap.test('Supports ECMAScript module packages', t => {
if (process.platform === 'win32') return t.skip('ESM support on windows is broken');
spawn('ecma-script-module-package/index.js', out => {
if (out.match(/touch ecma-script-module-package\/message.js/)) {
touchFile('ecma-script-module-package/message.js');
return out2 => {
if (out2.match(/Restarting/)) {
t.match(out2, /\[INFO\] \d{2}:\d{2}:\d{2} Restarting/);
return { exit: t.end.bind(t) };
}
};
}
});
});