Skip to content
Prev Previous commit
Next Next commit
test: add Uncaught SyntaxError case
  • Loading branch information
jenthone authored and meixg committed Aug 24, 2025
commit e367980ab4eb5a651761ae76c52ed4efd179d70c
19 changes: 17 additions & 2 deletions test/parallel/test-repl-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ async function tests(options) {
'aaaa\r',
'Uncaught ReferenceError: aaaa is not defined'
]
}, {
input: '/0',
noPreview: '/0',
preview: [
'/0\r',
'/0',
'^',
'',
'Uncaught SyntaxError: Invalid regular expression: missing /',
]
}];

const hasPreview = repl.terminal &&
Expand All @@ -184,8 +194,13 @@ async function tests(options) {
assert.deepStrictEqual(lines, preview);
} else {
assert.ok(lines[0].includes(noPreview), lines.map(inspect));
if (preview.length !== 1 || preview[0] !== `${input}\r`)
assert.strictEqual(lines.length, 2);
if (preview.length !== 1 || preview[0] !== `${input}\r`) {
if (preview[preview.length-1].includes('Uncaught SyntaxError')) { // Syntax error
assert.strictEqual(lines.length, 5);
} else {
assert.strictEqual(lines.length, 2);
}
}
}
}
}
Expand Down