node/test/es-module/test-esm-repl-imports.js
MURAKAMI Masahiko 06603c44a5
test_runner: avoid swallowing of asynchronously thrown errors
Fixes: https://github.com/nodejs/node/issues/44612
PR-URL: https://github.com/nodejs/node/pull/45264
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2022-11-07 12:02:56 +00:00

29 lines
709 B
JavaScript

'use strict';
const { mustCall } = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('node:assert');
const { spawn } = require('node:child_process');
const { execPath } = require('node:process');
const { describe, it } = require('node:test');
describe('ESM: REPL runs', { concurrency: true }, () => {
it((done) => {
const child = spawn(execPath, [
'--interactive',
], {
cwd: fixtures.path('es-modules', 'pkgimports'),
});
child.stdin.end(
'try{require("#test");await import("#test")}catch{process.exit(-1)}'
);
child.on('exit', mustCall((code) => {
assert.strictEqual(code, 0);
done();
}));
});
});