From 6a8249ecce40f2b53916a8054128ba2d1b79c35e Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Tue, 14 Jun 2022 22:24:05 +0300 Subject: [PATCH] no console --- lib/internal/test_runner/harness.js | 35 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/internal/test_runner/harness.js b/lib/internal/test_runner/harness.js index d034f91b4a712e..10dac48192e43f 100644 --- a/lib/internal/test_runner/harness.js +++ b/lib/internal/test_runner/harness.js @@ -4,7 +4,6 @@ const { createHook, executionAsyncId, } = require('async_hooks'); -const console = require('console'); const { codes: { ERR_TEST_FAILURE, @@ -22,24 +21,24 @@ function createProcessEventHandler(eventName, rootTest) { // Check if this error is coming from a test. If it is, fail the test. const test = testResources.get(executionAsyncId()); - if (test !== undefined) { - if (test.finished) { - // If the test is already finished, report this as a top level - // diagnostic since this is a malformed test. - const msg = `Warning: Test "${test.name}" generated asynchronous ` + - 'activity after the test ended. This activity created the error ' + - `"${err}" and would have caused the test to fail, but instead ` + - `triggered an ${eventName} event.`; - - rootTest.diagnostic(msg); - return; - } - - test.fail(new ERR_TEST_FAILURE(err, eventName)); - test.postRun(); - } else { - console.error(err); + if (test === undefined) { + throw err; + } + + if (test.finished) { + // If the test is already finished, report this as a top level + // diagnostic since this is a malformed test. + const msg = `Warning: Test "${test.name}" generated asynchronous ` + + 'activity after the test ended. This activity created the error ' + + `"${err}" and would have caused the test to fail, but instead ` + + `triggered an ${eventName} event.`; + + rootTest.diagnostic(msg); + return; } + + test.fail(new ERR_TEST_FAILURE(err, eventName)); + test.postRun(); }; }