MCPcopy Index your code
hub / github.com/nodejs/node / fail

Method fail

lib/internal/test_runner/test.js:1120–1155  ·  view source on GitHub ↗
(err)

Source from the content-addressed store, hash-verified

1118 }
1119
1120 fail(err) {
1121 if (this.error !== null) {
1122 return;
1123 }
1124
1125 if (this.expectFailure) {
1126 if (typeof this.expectFailure === 'object' &&
1127 this.expectFailure.match !== undefined) {
1128 const { match: validation } = this.expectFailure;
1129 try {
1130 const errorToCheck = (
1131 err?.code === 'ERR_TEST_FAILURE' &&
1132 err?.failureType === kTestCodeFailure &&
1133 err.cause
1134 ) ?
1135 err.cause :
1136 err;
1137 // eslint-disable-next-line no-restricted-syntax
1138 assert.throws(() => { throw errorToCheck; }, validation);
1139 } catch (e) {
1140 this.passed = false;
1141 this.error = new ERR_TEST_FAILURE(
1142 'The test failed, but the error did not match the expected validation',
1143 kTestCodeFailure,
1144 );
1145 this.error.cause = e;
1146 return;
1147 }
1148 }
1149 this.passed = true;
1150 } else {
1151 this.passed = false;
1152 }
1153
1154 this.error = err;
1155 }
1156
1157 pass() {
1158 if (this.error == null && this.expectFailure && !this.skipped) {

Callers 11

#cancelMethod · 0.95
createHookMethod · 0.95
runMethod · 0.95
postRunMethod · 0.95
runFunction · 0.45
createSubtestMethod · 0.45
reportMethod · 0.45
postRunMethod · 0.45
createBuildMethod · 0.45
runMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected