forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-esm-json.mjs
More file actions
24 lines (20 loc) · 841 Bytes
/
test-esm-json.mjs
File metadata and controls
24 lines (20 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { spawnPromisified } from '../common/index.mjs';
import * as fixtures from '../common/fixtures.mjs';
import assert from 'node:assert';
import { execPath } from 'node:process';
import { describe, it } from 'node:test';
import secret from '../fixtures/experimental.json' assert { type: 'json' };
describe('ESM: importing JSON', () => {
it('should load JSON', () => {
assert.strictEqual(secret.ofLife, 42);
});
it('should print an experimental warning', async () => {
const { code, signal, stderr } = await spawnPromisified(execPath, [
fixtures.path('/es-modules/json-modules.mjs'),
]);
assert.match(stderr, /ExperimentalWarning: Importing JSON modules/);
assert.match(stderr, /ExperimentalWarning: Import assertions/);
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
});
});