node/test/parallel/test-repl-strict-mode-previews.js
Adam Majer f76b28f2cf
test: skip some console tests on dumb terminal
This adds two more tests to be skipped on systems with only a
dumb terminal. See https://github.com/nodejs/node/pull/33165
for details.

PR-URL: https://github.com/nodejs/node/pull/37770
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2024-05-06 12:14:22 +00:00

48 lines
1.0 KiB
JavaScript

// Previews in strict mode should indicate ReferenceErrors.
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIfDumbTerminal();
if (process.argv[2] === 'child') {
const stream = require('stream');
const repl = require('repl');
class ActionStream extends stream.Stream {
readable = true;
run(data) {
this.emit('data', `${data}`);
this.emit('keypress', '', { ctrl: true, name: 'd' });
}
resume() {}
pause() {}
}
repl.start({
input: new ActionStream(),
output: new stream.Writable({
write(chunk, _, next) {
console.log(chunk.toString());
next();
}
}),
useColors: false,
terminal: true
}).inputStream.run('xyz');
} else {
const assert = require('assert');
const { spawnSync } = require('child_process');
const result = spawnSync(
process.execPath,
['--use-strict', `${__filename}`, 'child']
);
assert.match(
result.stdout.toString(),
/\/\/ ReferenceError: xyz is not defined/
);
}