summaryrefslogtreecommitdiff
path: root/test/parallel/test-repl-uncaught-exception.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-repl-uncaught-exception.js')
-rw-r--r--test/parallel/test-repl-uncaught-exception.js25
1 files changed, 15 insertions, 10 deletions
diff --git a/test/parallel/test-repl-uncaught-exception.js b/test/parallel/test-repl-uncaught-exception.js
index 447b69b1d4..28e62dff22 100644
--- a/test/parallel/test-repl-uncaught-exception.js
+++ b/test/parallel/test-repl-uncaught-exception.js
@@ -6,7 +6,7 @@ const repl = require('repl');
let count = 0;
-function run({ command, expected }) {
+function run({ command, expected, useColors = false }) {
let accum = '';
const output = new ArrayStream();
@@ -17,7 +17,7 @@ function run({ command, expected }) {
input: new ArrayStream(),
output,
terminal: false,
- useColors: false
+ useColors
});
r.write(`${command}\n`);
@@ -30,35 +30,40 @@ function run({ command, expected }) {
// Verify that the repl is still working as expected.
accum = '';
r.write('1 + 1\n');
- assert.strictEqual(accum, '2\n');
+ // eslint-disable-next-line no-control-regex
+ assert.strictEqual(accum.replace(/\u001b\[[0-9]+m/g, ''), '2\n');
r.close();
count++;
}
const tests = [
{
+ useColors: true,
command: 'x',
- expected: 'Thrown:\n' +
- 'ReferenceError: x is not defined\n'
+ expected: 'Uncaught ReferenceError: x is not defined\n'
+ },
+ {
+ useColors: true,
+ command: 'throw { foo: "test" }',
+ expected: "Uncaught { foo: \x1B[32m'test'\x1B[39m }\n"
},
{
command: 'process.on("uncaughtException", () => console.log("Foobar"));\n',
- expected: /^Thrown:\nTypeError \[ERR_INVALID_REPL_INPUT]: Listeners for `/
+ expected: /^Uncaught:\nTypeError \[ERR_INVALID_REPL_INPUT]: Listeners for `/
},
{
command: 'x;\n',
- expected: 'Thrown:\n' +
- 'ReferenceError: x is not defined\n'
+ expected: 'Uncaught ReferenceError: x is not defined\n'
},
{
command: 'process.on("uncaughtException", () => console.log("Foobar"));' +
'console.log("Baz");\n',
- expected: /^Thrown:\nTypeError \[ERR_INVALID_REPL_INPUT]: Listeners for `/
+ expected: /^Uncaught:\nTypeError \[ERR_INVALID_REPL_INPUT]: Listeners for `/
},
{
command: 'console.log("Baz");' +
'process.on("uncaughtException", () => console.log("Foobar"));\n',
- expected: /^Baz\nThrown:\nTypeError \[ERR_INVALID_REPL_INPUT]:.*uncaughtException/
+ expected: /^Baz\nUncaught:\nTypeError \[ERR_INVALID_REPL_INPUT]:.*uncaughtException/
}
];