Make changes so that tests will pass when the comma-dangle settings applied to the rest of the code base are also applied to tests. PR-URL: https://github.com/nodejs/node/pull/37930 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
29 lines
793 B
JavaScript
29 lines
793 B
JavaScript
// Flags: --experimental-json-modules
|
|
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';
|
|
|
|
strictEqual(secret.ofLife, 42);
|
|
|
|
// Test warning message
|
|
const child = spawn(process.execPath, [
|
|
'--experimental-json-modules',
|
|
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'
|
|
));
|
|
});
|