MCPcopy Create free account
hub / github.com/nodejs/node / Test

Class Test

lib/internal/test_runner/test.js:561–1698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561class Test extends AsyncResource {
562 reportedType = 'test';
563 abortController;
564 outerSignal;
565 #reportedSubtest;
566 #tagsArray = null;
567
568 constructor(options) {
569 super('Test');
570
571 let { fn, name, parent } = options;
572 const { concurrency, entryFile, expectFailure, loc, only, timeout, todo, skip, signal, plan } = options;
573 const rawTags = options.tags;
574
575 if (typeof fn !== 'function') {
576 fn = noop;
577 }
578
579 if (typeof name !== 'string' || name === '') {
580 name = fn.name || '<anonymous>';
581 }
582
583 if (!(parent instanceof Test)) {
584 parent = null;
585 }
586
587 this.name = name;
588 this.parent = parent;
589 this.testNumber = 0;
590 this.outputSubtestCount = 0;
591 this.diagnostics = [];
592 this.filtered = false;
593 this.filteredByName = false;
594 this.filteredByTag = false;
595 this.hasOnlyTests = false;
596
597 // Hooks pass no tags option, so rawTags is undefined for them.
598 const ownTags = rawTags !== undefined ?
599 validateAndCanonicalizeTagValues(rawTags, 'options.tags') :
600 kEmptyTagArray;
601
602 const ownTagSet = new SafeSet(ownTags);
603 this.tagSet = parent !== null && parent.tagSet.size > 0 ?
604 SetPrototypeUnion(parent.tagSet, ownTagSet) :
605 ownTagSet;
606
607 if (parent === null) {
608 this.root = this;
609 this.harness = options.harness;
610 this.config = this.harness.config;
611 this.concurrency = 1;
612 this.nesting = 0;
613 this.only = this.config.only;
614 this.reporter = new TestsStream();
615 this.runOnlySubtests = this.only;
616 this.childNumber = 0;
617 this.timeout = kDefaultTimeout;
618 this.entryFile = entryFile;

Callers

nothing calls this directly

Calls 1

#cancelMethod · 0.95

Tested by

no test coverage detected