( usedFixtures: TestFixtureItem[], registrations: FixtureRegistrations, depSet = new Set<TestFixtureItem>(), pendingFixtures: TestFixtureItem[] = [], )
| 552 | } |
| 553 | |
| 554 | function resolveDeps( |
| 555 | usedFixtures: TestFixtureItem[], |
| 556 | registrations: FixtureRegistrations, |
| 557 | depSet = new Set<TestFixtureItem>(), |
| 558 | pendingFixtures: TestFixtureItem[] = [], |
| 559 | ) { |
| 560 | usedFixtures.forEach((fixture) => { |
| 561 | if (pendingFixtures.includes(fixture)) { |
| 562 | return |
| 563 | } |
| 564 | if (!isFixtureFunction(fixture.value) || !fixture.deps) { |
| 565 | pendingFixtures.push(fixture) |
| 566 | return |
| 567 | } |
| 568 | if (depSet.has(fixture)) { |
| 569 | if (fixture.parent) { |
| 570 | fixture = fixture.parent |
| 571 | } |
| 572 | else { |
| 573 | throw new Error( |
| 574 | `Circular fixture dependency detected: ${fixture.name} <- ${[...depSet] |
| 575 | .reverse() |
| 576 | .map(d => d.name) |
| 577 | .join(' <- ')}`, |
| 578 | ) |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | depSet.add(fixture) |
| 583 | resolveDeps( |
| 584 | [...fixture.deps].map(n => n === fixture.name ? fixture.parent : registrations.get(n)).filter(n => !!n), |
| 585 | registrations, |
| 586 | depSet, |
| 587 | pendingFixtures, |
| 588 | ) |
| 589 | pendingFixtures.push(fixture) |
| 590 | depSet.clear() |
| 591 | }) |
| 592 | |
| 593 | return pendingFixtures |
| 594 | } |
| 595 | |
| 596 | function validateSuiteHook(fn: Function, hook: SuiteHook, suiteError: Error | undefined) { |
| 597 | const usedProps = getUsedProps(fn, { sourceError: suiteError, suiteHook: hook }) |
no test coverage detected