PR-URL: https://github.com/nodejs/node/pull/41736 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
27 lines
746 B
JavaScript
27 lines
746 B
JavaScript
import '../common/index.mjs';
|
|
import { path } from '../common/fixtures.mjs';
|
|
import { strictEqual, ok } from 'assert';
|
|
import { spawn } from 'child_process';
|
|
|
|
import secret from '../fixtures/experimental.json' assert { type: 'json' };
|
|
|
|
strictEqual(secret.ofLife, 42);
|
|
|
|
// Test warning message
|
|
const child = spawn(process.execPath, [
|
|
path('/es-modules/json-modules.mjs'),
|
|
]);
|
|
|
|
let stderr = '';
|
|
child.stderr.setEncoding('utf8');
|
|
child.stderr.on('data', (data) => {
|
|
stderr += data;
|
|
});
|
|
child.on('close', (code, signal) => {
|
|
strictEqual(code, 0);
|
|
strictEqual(signal, null);
|
|
ok(stderr.toString().includes(
|
|
'ExperimentalWarning: Importing JSON modules is an experimental feature. ' +
|
|
'This feature could change at any time'
|
|
));
|
|
});
|