diff --git a/graal-nodejs/lib/internal/test_runner/reporter/tap.js b/graal-nodejs/lib/internal/test_runner/reporter/tap.js index 9c737efef35..de8188c58dd 100644 --- a/graal-nodejs/lib/internal/test_runner/reporter/tap.js +++ b/graal-nodejs/lib/internal/test_runner/reporter/tap.js @@ -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); diff --git a/graal-nodejs/test/fixtures/test-runner/output/hooks.snapshot b/graal-nodejs/test/fixtures/test-runner/output/hooks.snapshot index 5b16957ba24..b9fd2364037 100644 --- a/graal-nodejs/test/fixtures/test-runner/output/hooks.snapshot +++ b/graal-nodejs/test/fixtures/test-runner/output/hooks.snapshot @@ -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: |- *