Skip to content

Commit 79e1831

Browse files
Trottevanlucas
authored andcommitted
test: make error stack test engine agnostic
Revise test-internal-util-decorate-error-stack so that it does not depend on behavior specific to V8. PR-URL: #16272 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent b5b23bd commit 79e1831

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/parallel/test-internal-util-decorate-error-stack.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ const obj = {};
2424
decorateErrorStack(obj);
2525
assert.strictEqual(obj.stack, undefined);
2626

27-
// Verify that the stack is decorated when possible
27+
// Verify that the stack is decorated when possible.
2828
function checkStack(stack) {
29-
const matches = stack.match(/var foo bar;/g);
30-
assert.strictEqual(Array.isArray(matches), true);
31-
assert.strictEqual(matches.length, 1);
29+
// Matching only on a minimal piece of the stack because the string will vary
30+
// greatly depending on the JavaScript engine. V8 includes `;` because it
31+
// displays the line of code (`var foo bar;`) that is causing a problem.
32+
// ChakraCore does not display the line of code but includes `;` in the phrase
33+
// `Expected ';' `.
34+
assert.ok(/;/g.test(stack));
35+
// Test that it's a multiline string.
36+
assert.ok(/\n/g.test(stack));
3237
}
3338
let err;
3439
const badSyntaxPath =

0 commit comments

Comments
 (0)