Skip to content

Commit 853f572

Browse files
author
Yiyun Lei
authored
test: migrate message error tests from Python to JS
Migrate the remaining error tests in the `test/message` folder from Python to JS. Fixes: #47707 PR-URL: #49721 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent 85172c3 commit 853f572

29 files changed

+112
-101
lines changed

test/message/core_line_numbers.js renamed to test/fixtures/errors/core_line_numbers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
require('../../common');
33
Error.stackTraceLimit = 3;
44

55
const punycode = require('punycode');

test/message/core_line_numbers.out renamed to test/fixtures/errors/core_line_numbers.snapshot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ node:punycode:49
44

55
RangeError: Invalid input
66
at error (node:punycode:49:8)
7-
at Object.decode (node:punycode:*:*)
8-
at Object.<anonymous> (*test*message*core_line_numbers.js:*:*)
7+
at Object.decode (node:punycode:242:5)
8+
at Object.<anonymous> (*core_line_numbers.js:13:10)
99

1010
Node.js *

test/message/if-error-has-good-stack.js renamed to test/fixtures/errors/if-error-has-good-stack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
require('../common');
3+
require('../../common');
44
Error.stackTraceLimit = 4;
55

66
const assert = require('assert');

test/message/if-error-has-good-stack.out renamed to test/fixtures/errors/if-error-has-good-stack.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ node:assert:*
33
^
44

55
AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
6-
at z (*if-error-has-good-stack.js:*:*
6+
at z (*if-error-has-good-stack.js:*:*)
77
at y (*if-error-has-good-stack.js:*:*)
88
at x (*if-error-has-good-stack.js:*:*)
99
at Object.<anonymous> (*if-error-has-good-stack.js:*:*)

test/message/promise_unhandled_warn_with_error.js renamed to test/fixtures/errors/promise_unhandled_warn_with_error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Flags: --unhandled-rejections=warn-with-error-code
22
'use strict';
33

4-
require('../common');
4+
require('../../common');
55
const assert = require('assert');
66

77
Promise.reject(new Error('alas'));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(node:*) UnhandledPromiseRejectionWarning: Error: alas
2+
at *
3+
at *
4+
at *
5+
at *
6+
at *
7+
at *
8+
at *
9+
(Use `node --trace-warnings ...` to show where the warning was created)
10+
(node:*) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https:*nodejs.org*api*cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Flags: --no-extra-info-on-fatal-exception
22

33
'use strict';
4-
require('../common');
4+
require('../../common');
55
Error.stackTraceLimit = 1;
66

77
throw new Error('foo');
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*test-no-extra-info-on-fatal-exception.js:7
2+
throw new Error('foo');
3+
^
4+
5+
Error: foo
6+
at Object.<anonymous> (*test-no-extra-info-on-fatal-exception.js:7:7)

test/message/throw_error_with_getter_throw.js renamed to test/fixtures/errors/throw_error_with_getter_throw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
require('../../common');
33
throw { // eslint-disable-line no-throw-literal
44
get stack() {
55
throw new Error('weird throw but ok');
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
*throw_error_with_getter_throw.js:*
3+
throw { * eslint-disable-line no-throw-literal
4+
^
5+
[object Object]
6+
(Use `node --trace-uncaught ...` to show where the exception was thrown)
7+
8+
Node.js *

0 commit comments

Comments
 (0)