diff --git a/test/parallel/test-internal-util-decorate-error-stack.js b/test/parallel/test-internal-util-decorate-error-stack.js index d428e3c7ee2a7b..b5670135a028ad 100644 --- a/test/parallel/test-internal-util-decorate-error-stack.js +++ b/test/parallel/test-internal-util-decorate-error-stack.js @@ -24,11 +24,16 @@ const obj = {}; decorateErrorStack(obj); assert.strictEqual(obj.stack, undefined); -// Verify that the stack is decorated when possible +// Verify that the stack is decorated when possible. function checkStack(stack) { - const matches = stack.match(/var foo bar;/g); - assert.strictEqual(Array.isArray(matches), true); - assert.strictEqual(matches.length, 1); + // Matching only on a minimal piece of the stack because the string will vary + // greatly depending on the JavaScript engine. V8 includes `;` because it + // displays the line of code (`var foo bar;`) that is causing a problem. + // ChakraCore does not display the line of code but includes `;` in the phrase + // `Expected ';' `. + assert.ok(/;/g.test(stack)); + // Test that it's a multiline string. + assert.ok(/\n/g.test(stack)); } let err; const badSyntaxPath =