UNPKG

jest-metadata

Version:

🦸‍♂️ Superhero power for your Jest reporters! 🦸‍♀️

56 lines 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TestInvocationMetadata = void 0; const tslib_1 = require("tslib"); const symbols = tslib_1.__importStar(require("../symbols")); const BaseMetadata_1 = require("./BaseMetadata"); class TestInvocationMetadata extends BaseMetadata_1.BaseMetadata { definition; beforeAll = []; beforeEach = []; fn; afterEach = []; afterAll = []; constructor(context, definition, id) { super(context, id); this.definition = definition; } get file() { return this.definition.file; } [symbols.start]() { const id = this[symbols.id].nest('fn'); const fn = this[symbols.context].factory.createTestFnInvocationMetadata(this, id); const file = this.definition.describeBlock.file; file[symbols.currentMetadata] = this.fn = fn; this.definition.describeBlock[symbols.pushBeforeAll](this); } [symbols.pushBeforeAll](metadatas) { this.beforeAll.push(...metadatas); } [symbols.pushAfterAll](metadatas) { this.afterAll.push(...metadatas); } [symbols.finish]() { const file = this.definition.describeBlock.file; file[symbols.currentMetadata] = this; } *invocations() { yield* this.beforeEach; if (this.fn) { yield this.fn; } yield* this.afterEach; } *allInvocations() { yield* this.beforeAll; yield* this.invocations(); yield* this.afterAll; } *allAncestors() { yield this.definition; yield* this.definition.allAncestors(); } } exports.TestInvocationMetadata = TestInvocationMetadata; //# sourceMappingURL=TestInvocationMetadata.js.map