Skip to content

Commit

Permalink
no console
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Jun 14, 2022
1 parent 878cf24 commit 6a8249e
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions lib/internal/test_runner/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {
createHook,
executionAsyncId,
} = require('async_hooks');
const console = require('console');
const {
codes: {
ERR_TEST_FAILURE,
Expand All @@ -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();
};
}

Expand Down

0 comments on commit 6a8249e

Please sign in to comment.