mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test_runner: unwrap error message in TAP reporter
The TAP reporter unwraps errors that come from user code. It was not properly unwrapping the error message when the failure originated from a test hook. This lead to difficult to debug errors when TAP output was used. This commit updates the TAP reporter to properly unwrap the error message. Fixes: https://github.com/nodejs/node/issues/48941 PR-URL: https://github.com/nodejs/node/pull/48942 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
1 parent
d7ed3a4abc
commit
bef3942820
2 files changed
+17
-18
No files matched your search
@@ -171,7 +171,7 @@ function jsToYaml(indent, name, value, seen) {
|
||||
}
|
||||
|
||||
if (isErrorObj) {
|
||||
const { kTestCodeFailure, kUnwrapErrors } = lazyLoadTest();
|
||||
const { kUnwrapErrors } = lazyLoadTest();
|
||||
const {
|
||||
cause,
|
||||
code,
|
||||
@@ -198,15 +198,14 @@ function jsToYaml(indent, name, value, seen) {
|
||||
errStack = cause?.stack ?? errStack;
|
||||
errCode = cause?.code ?? errCode;
|
||||
errName = cause?.name ?? errName;
|
||||
errMsg = cause?.message ?? errMsg;
|
||||
|
||||
if (isAssertionLike(cause)) {
|
||||
errExpected = cause.expected;
|
||||
errActual = cause.actual;
|
||||
errOperator = cause.operator ?? errOperator;
|
||||
errIsAssertion = true;
|
||||
}
|
||||
if (failureType === kTestCodeFailure) {
|
||||
errMsg = cause?.message ?? errMsg;
|
||||
}
|
||||
}
|
||||
|
||||
result += jsToYaml(indent, 'error', errMsg, seen);
|
||||
|
||||
+14
-14
@@ -56,7 +56,7 @@ not ok 2 - before throws
|
||||
duration_ms: *
|
||||
type: 'suite'
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running before hook'
|
||||
error: 'before'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -86,7 +86,7 @@ not ok 3 - after throws
|
||||
duration_ms: *
|
||||
type: 'suite'
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running after hook'
|
||||
error: 'after'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -105,7 +105,7 @@ not ok 3 - after throws
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running beforeEach hook'
|
||||
error: 'beforeEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -124,7 +124,7 @@ not ok 3 - after throws
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running beforeEach hook'
|
||||
error: 'beforeEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -153,7 +153,7 @@ not ok 4 - beforeEach throws
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running afterEach hook'
|
||||
error: 'afterEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -172,7 +172,7 @@ not ok 4 - beforeEach throws
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running afterEach hook'
|
||||
error: 'afterEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -254,7 +254,7 @@ not ok 6 - afterEach when test fails
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running afterEach hook'
|
||||
error: 'afterEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -315,7 +315,7 @@ ok 8 - test hooks
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running before hook'
|
||||
error: 'before'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -334,7 +334,7 @@ ok 8 - test hooks
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running before hook'
|
||||
error: 'before'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -362,7 +362,7 @@ not ok 9 - t.before throws
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running beforeEach hook'
|
||||
error: 'beforeEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -381,7 +381,7 @@ not ok 9 - t.before throws
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running beforeEach hook'
|
||||
error: 'beforeEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -409,7 +409,7 @@ not ok 10 - t.beforeEach throws
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running afterEach hook'
|
||||
error: 'afterEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -428,7 +428,7 @@ not ok 10 - t.beforeEach throws
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running afterEach hook'
|
||||
error: 'afterEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
@@ -506,7 +506,7 @@ not ok 12 - afterEach when test fails
|
||||
---
|
||||
duration_ms: *
|
||||
failureType: 'hookFailed'
|
||||
error: 'failed running afterEach hook'
|
||||
error: 'afterEach'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user