test: migrate message error tests from Python to JS
Migrate the remaining error tests in the `test/message` folder from Python to JS. Fixes: https://github.com/nodejs/node/issues/47707 PR-URL: https://github.com/nodejs/node/pull/49721 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
parent
85172c322f
commit
853f57239c
@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
require('../../common');
|
||||
Error.stackTraceLimit = 3;
|
||||
|
||||
const punycode = require('punycode');
|
@ -4,7 +4,7 @@ node:punycode:49
|
||||
|
||||
RangeError: Invalid input
|
||||
at error (node:punycode:49:8)
|
||||
at Object.decode (node:punycode:*:*)
|
||||
at Object.<anonymous> (*test*message*core_line_numbers.js:*:*)
|
||||
at Object.decode (node:punycode:242:5)
|
||||
at Object.<anonymous> (*core_line_numbers.js:13:10)
|
||||
|
||||
Node.js *
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
require('../../common');
|
||||
Error.stackTraceLimit = 4;
|
||||
|
||||
const assert = require('assert');
|
@ -3,7 +3,7 @@ node:assert:*
|
||||
^
|
||||
|
||||
AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
|
||||
at z (*if-error-has-good-stack.js:*:*
|
||||
at z (*if-error-has-good-stack.js:*:*)
|
||||
at y (*if-error-has-good-stack.js:*:*)
|
||||
at x (*if-error-has-good-stack.js:*:*)
|
||||
at Object.<anonymous> (*if-error-has-good-stack.js:*:*)
|
@ -1,7 +1,7 @@
|
||||
// Flags: --unhandled-rejections=warn-with-error-code
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
require('../../common');
|
||||
const assert = require('assert');
|
||||
|
||||
Promise.reject(new Error('alas'));
|
10
test/fixtures/errors/promise_unhandled_warn_with_error.snapshot
vendored
Normal file
10
test/fixtures/errors/promise_unhandled_warn_with_error.snapshot
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
(node:*) UnhandledPromiseRejectionWarning: Error: alas
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
(Use `node --trace-warnings ...` to show where the warning was created)
|
||||
(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)
|
@ -1,7 +1,7 @@
|
||||
// Flags: --no-extra-info-on-fatal-exception
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
require('../../common');
|
||||
Error.stackTraceLimit = 1;
|
||||
|
||||
throw new Error('foo');
|
6
test/fixtures/errors/test-no-extra-info-on-fatal-exception.snapshot
vendored
Normal file
6
test/fixtures/errors/test-no-extra-info-on-fatal-exception.snapshot
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
*test-no-extra-info-on-fatal-exception.js:7
|
||||
throw new Error('foo');
|
||||
^
|
||||
|
||||
Error: foo
|
||||
at Object.<anonymous> (*test-no-extra-info-on-fatal-exception.js:7:7)
|
@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
require('../../common');
|
||||
throw { // eslint-disable-line no-throw-literal
|
||||
get stack() {
|
||||
throw new Error('weird throw but ok');
|
8
test/fixtures/errors/throw_error_with_getter_throw.snapshot
vendored
Normal file
8
test/fixtures/errors/throw_error_with_getter_throw.snapshot
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
*throw_error_with_getter_throw.js:*
|
||||
throw { * eslint-disable-line no-throw-literal
|
||||
^
|
||||
[object Object]
|
||||
(Use `node --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
require('../../common');
|
||||
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw null;
|
8
test/fixtures/errors/throw_null.snapshot
vendored
Normal file
8
test/fixtures/errors/throw_null.snapshot
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
*throw_null.js:*
|
||||
throw null;
|
||||
^
|
||||
null
|
||||
(Use `node --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
require('../../common');
|
||||
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw undefined;
|
8
test/fixtures/errors/throw_undefined.snapshot
vendored
Normal file
8
test/fixtures/errors/throw_undefined.snapshot
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
*throw_undefined.js:*
|
||||
throw undefined;
|
||||
^
|
||||
undefined
|
||||
(Use `node --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
require('../../common');
|
||||
|
||||
setTimeout(function() {
|
||||
// eslint-disable-next-line no-undef,no-unused-expressions
|
10
test/fixtures/errors/timeout_throw.snapshot
vendored
Normal file
10
test/fixtures/errors/timeout_throw.snapshot
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
*timeout_throw.js:*
|
||||
undefined_reference_error_maker;
|
||||
^
|
||||
|
||||
ReferenceError: undefined_reference_error_maker is not defined
|
||||
at Timeout._onTimeout (*timeout_throw.js:*:*)
|
||||
at listOnTimeout (node:internal*timers:*:*)
|
||||
at process.processTimers (node:internal*timers:*:*)
|
||||
|
||||
Node.js *
|
@ -20,7 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
'use strict';
|
||||
require('../common');
|
||||
require('../../common');
|
||||
const vm = require('vm');
|
||||
|
||||
console.error('before');
|
13
test/fixtures/errors/undefined_reference_in_new_context.snapshot
vendored
Normal file
13
test/fixtures/errors/undefined_reference_in_new_context.snapshot
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
before
|
||||
evalmachine.<anonymous>:*
|
||||
Error.stackTraceLimit = 5; foo.bar = 5;
|
||||
^
|
||||
|
||||
ReferenceError: foo is not defined
|
||||
at evalmachine.<anonymous>:*:*
|
||||
at Script.runInContext (node:vm:*:*)
|
||||
at Script.runInNewContext (node:vm:*:*)
|
||||
at Object.runInNewContext (node:vm:*:*)
|
||||
at Object.<anonymous> (*undefined_reference_in_new_context.js:*:*)
|
||||
|
||||
Node.js *
|
@ -1,5 +1,5 @@
|
||||
// Flags: --trace-warnings --unhandled-rejections=warn
|
||||
'use strict';
|
||||
require('../common');
|
||||
require('../../common');
|
||||
const p = Promise.reject(new Error('This was rejected'));
|
||||
setImmediate(() => p.catch(() => {}));
|
26
test/fixtures/errors/unhandled_promise_trace_warnings.snapshot
vendored
Normal file
26
test/fixtures/errors/unhandled_promise_trace_warnings.snapshot
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
(node:*) UnhandledPromiseRejectionWarning: Error: This was rejected
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
(node:*) Error: This was rejected
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
(node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
|
||||
at *
|
||||
at *
|
||||
at Promise.then (<anonymous>)
|
||||
at Promise.catch (<anonymous>)
|
||||
at *
|
||||
at *
|
@ -1,10 +0,0 @@
|
||||
*UnhandledPromiseRejectionWarning: Error: alas
|
||||
at *promise_unhandled_warn_with_error.js:*:*
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
(Use `* --trace-warnings ...` to show where the warning was created)
|
||||
*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)
|
@ -1,6 +0,0 @@
|
||||
*:7
|
||||
throw new Error('foo');
|
||||
^
|
||||
|
||||
Error: foo
|
||||
at Object.<anonymous> (*:7:7)
|
@ -1,8 +0,0 @@
|
||||
|
||||
*:3
|
||||
throw { // eslint-disable-line no-throw-literal
|
||||
^
|
||||
[object Object]
|
||||
(Use `* --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
@ -1,8 +0,0 @@
|
||||
|
||||
*test*message*throw_null.js:*
|
||||
throw null;
|
||||
^
|
||||
null
|
||||
(Use `* --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
@ -1,8 +0,0 @@
|
||||
|
||||
*test*message*throw_undefined.js:*
|
||||
throw undefined;
|
||||
^
|
||||
undefined
|
||||
(Use `* --trace-uncaught ...` to show where the exception was thrown)
|
||||
|
||||
Node.js *
|
@ -1,9 +0,0 @@
|
||||
*test*message*timeout_throw.js:*
|
||||
undefined_reference_error_maker;
|
||||
^
|
||||
ReferenceError: undefined_reference_error_maker is not defined
|
||||
at Timeout._onTimeout (*test*message*timeout_throw.js:*:*)
|
||||
at listOnTimeout (node:internal/timers:*:*)
|
||||
at process.processTimers (node:internal/timers:*:*)
|
||||
|
||||
Node.js *
|
@ -1,13 +0,0 @@
|
||||
before
|
||||
evalmachine.<anonymous>:1
|
||||
Error.stackTraceLimit = 5; foo.bar = 5;
|
||||
^
|
||||
|
||||
ReferenceError: foo is not defined
|
||||
at evalmachine.<anonymous>:*:*
|
||||
at Script.runInContext (node:vm:*)
|
||||
at Script.runInNewContext (node:vm:*)
|
||||
at Object.runInNewContext (node:vm:*)
|
||||
at Object.<anonymous> (*test*message*undefined_reference_in_new_context.js:*)
|
||||
|
||||
Node.js *
|
@ -1,26 +0,0 @@
|
||||
(node:*) UnhandledPromiseRejectionWarning: Error: This was rejected
|
||||
at * (*test*message*unhandled_promise_trace_warnings.js:*)
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
(node:*) Error: This was rejected
|
||||
at * (*test*message*unhandled_promise_trace_warnings.js:*)
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
at *
|
||||
(node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
|
||||
at handledRejection (node:internal/process/promises:*)
|
||||
at promiseRejectHandler (node:internal/process/promises:*)
|
||||
at Promise.then *
|
||||
at Promise.catch *
|
||||
at Immediate.<anonymous> (*test*message*unhandled_promise_trace_warnings.js:*)
|
||||
at *
|
@ -49,7 +49,9 @@ describe('errors output', { concurrency: true }, () => {
|
||||
{ name: 'errors/async_error_microtask_main.js' },
|
||||
{ name: 'errors/async_error_nexttick_main.js' },
|
||||
{ name: 'errors/async_error_sync_main.js' },
|
||||
{ name: 'errors/core_line_numbers.js' },
|
||||
{ name: 'errors/async_error_sync_esm.mjs' },
|
||||
{ name: 'errors/test-no-extra-info-on-fatal-exception.js' },
|
||||
{ name: 'errors/error_aggregateTwoErrors.js', transform: errTransform },
|
||||
{ name: 'errors/error_exit.js', transform: errTransform },
|
||||
{ name: 'errors/error_with_nul.js', transform: errTransform },
|
||||
@ -57,10 +59,18 @@ describe('errors output', { concurrency: true }, () => {
|
||||
{ name: 'errors/events_unhandled_error_nexttick.js', transform: errTransform },
|
||||
{ name: 'errors/events_unhandled_error_sameline.js', transform: errTransform },
|
||||
{ name: 'errors/events_unhandled_error_subclass.js', transform: errTransform },
|
||||
{ name: 'errors/if-error-has-good-stack.js', transform: errTransform },
|
||||
{ name: 'errors/throw_custom_error.js', transform: errTransform },
|
||||
{ name: 'errors/throw_error_with_getter_throw.js', transform: errTransform },
|
||||
{ name: 'errors/throw_in_line_with_tabs.js', transform: errTransform },
|
||||
{ name: 'errors/throw_non_error.js', transform: errTransform },
|
||||
{ name: 'errors/throw_null.js', transform: errTransform },
|
||||
{ name: 'errors/throw_undefined.js', transform: errTransform },
|
||||
{ name: 'errors/timeout_throw.js', transform: errTransform },
|
||||
{ name: 'errors/undefined_reference_in_new_context.js', transform: errTransform },
|
||||
{ name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform },
|
||||
{ name: 'errors/promise_unhandled_warn_with_error.js', transform: promiseTransform },
|
||||
{ name: 'errors/unhandled_promise_trace_warnings.js', transform: promiseTransform },
|
||||
{ skip: skipForceColors, name: 'errors/force_colors.js',
|
||||
transform: forceColorsTransform, env: { FORCE_COLOR: 1 } },
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user