Skip to content

Commit 3d8ec8f

Browse files
Trotttargos
authored andcommitted
test: make url-parse-invalid-input engine agnostic
test-url-parse-invalid-input checks the message of an error that is generated by the JavaScript engine. Error messages that change in the underlying JavaScript engine should not be breaking changes in Node.js and therefore should not cause tests to fail. Remove the message check and replace it with a check of the type of the Error object along with the absence of a `code` property. (If a `code` property were present, it would indicate that the error was coming from Node.js rather than the JavaScript engine.) This also makes this test usable without modification in the ChakraCore fork of Node.js. PR-URL: #21132 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent fe5d351 commit 3d8ec8f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/parallel/test-url-parse-invalid-input.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ const url = require('url');
2626
});
2727

2828
assert.throws(() => { url.parse('http://%E0%A4%A@fail'); },
29-
/^URIError: URI malformed$/);
29+
(e) => {
30+
// The error should be a URIError.
31+
if (!(e instanceof URIError))
32+
return false;
33+
34+
// The error should be from the JS engine and not from Node.js.
35+
// JS engine errors do not have the `code` property.
36+
return e.code === undefined;
37+
});

0 commit comments

Comments
 (0)