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

Method run

lib/internal/test_runner/test.js:1288–1474  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1286 }
1287
1288 async run() {
1289 if (this.parent !== null) {
1290 this.parent.activeSubtests++;
1291 this.computeInheritedHooks();
1292 }
1293 this.startTime ??= hrtime();
1294
1295 // Channel context object shared across all lifecycle events for this test run.
1296 // Only tests emit events; hooks do not. This way, the test's span encompasses
1297 // its before/beforeEach hooks, the test body, and its afterEach/after hooks.
1298 const channelContext = this.hookType === undefined ? {
1299 __proto__: null,
1300 name: this.name,
1301 nesting: this.nesting,
1302 file: this.entryFile,
1303 type: this.reportedType,
1304 } : null;
1305
1306 if (this[kShouldAbort]()) {
1307 this.postRun();
1308 return;
1309 }
1310
1311 const hookArgs = this.getRunArgs();
1312 const { args, ctx } = hookArgs;
1313
1314 if (this.plan === null && this.expectedAssertions) {
1315 ctx.plan(this.expectedAssertions);
1316 }
1317
1318 const wasSkippedBeforeRun = this.skipped;
1319
1320 const after = async () => {
1321 if (this.hooks.after.length > 0) {
1322 await this.runHook('after', hookArgs);
1323 }
1324 };
1325 const afterEach = runOnce(async () => {
1326 if (this.parent?.hooks.afterEach.length > 0 && !wasSkippedBeforeRun) {
1327 await this.parent.runHook('afterEach', hookArgs);
1328 }
1329 }, kRunOnceOptions);
1330
1331 let stopPromise;
1332
1333 let publishEnd = () => testChannel.end.publish(channelContext);
1334 let publishError = (err) => testChannel.error.publish({ __proto__: null, ...channelContext, error: err });
1335
1336 try {
1337 if (this.parent?.hooks.before.length > 0) {
1338 // This hook usually runs immediately, we need to wait for it to finish
1339 await this.parent.runHook('before', this.parent.getRunArgs());
1340 }
1341 if (this.parent?.hooks.beforeEach.length > 0 && !this.skipped) {
1342 await this.parent.runHook('beforeEach', hookArgs);
1343 }
1344 stopPromise = stopTest(this.timeout, this.signal);
1345 const runArgs = ArrayPrototypeSlice(args);

Callers 15

startMethod · 0.95
constructorMethod · 0.45
jobPromiseFunction · 0.45
pbkdf2Function · 0.45
pbkdf2SyncFunction · 0.45
randomFillSyncFunction · 0.45
randomFillFunction · 0.45
generatePrimeFunction · 0.45
generatePrimeSyncFunction · 0.45
checkPrimeFunction · 0.45
checkPrimeSyncFunction · 0.45
generateKeyPairFunction · 0.45

Calls 15

computeInheritedHooksMethod · 0.95
postRunMethod · 0.95
getRunArgsMethod · 0.95
failMethod · 0.95
passMethod · 0.95
#cancelMethod · 0.95
hrtimeFunction · 0.85
stopTestFunction · 0.85
createDeferredCallbackFunction · 0.85
isTestFailureErrorFunction · 0.85
runHookMethod · 0.80
abortMethod · 0.65

Tested by

no test coverage detected