( fixtures: TestFixtures, suite: Suite, fixture: TestFixtureItem, )
| 456 | const scopedFixturePromiseCache = new WeakMap<TestFixtureItem, Promise<unknown>>() |
| 457 | |
| 458 | async function resolveScopeFixtureValue( |
| 459 | fixtures: TestFixtures, |
| 460 | suite: Suite, |
| 461 | fixture: TestFixtureItem, |
| 462 | ) { |
| 463 | const workerContext = fixtures.getWorkerContext() |
| 464 | const fileContext = fixtures.getFileContext(suite.file) |
| 465 | const fixtureContext = fixture.scope === 'worker' ? workerContext : fileContext |
| 466 | |
| 467 | if (!isFixtureFunction(fixture.value)) { |
| 468 | fixtureContext[fixture.name] = fixture.value |
| 469 | return fixture.value |
| 470 | } |
| 471 | |
| 472 | if (fixture.name in fixtureContext) { |
| 473 | return fixtureContext[fixture.name] |
| 474 | } |
| 475 | |
| 476 | if (scopedFixturePromiseCache.has(fixture)) { |
| 477 | return scopedFixturePromiseCache.get(fixture)! |
| 478 | } |
| 479 | |
| 480 | if (!cleanupFnArrayMap.has(fixtureContext)) { |
| 481 | cleanupFnArrayMap.set(fixtureContext, []) |
| 482 | } |
| 483 | const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext)! |
| 484 | |
| 485 | const promise = resolveFixtureFunction( |
| 486 | fixture.value, |
| 487 | fixture.name, |
| 488 | fixture.scope === 'file' ? { ...workerContext, ...fileContext } : fixtureContext, |
| 489 | cleanupFnFileArray, |
| 490 | ).then((value) => { |
| 491 | fixtureContext[fixture.name] = value |
| 492 | scopedFixturePromiseCache.delete(fixture) |
| 493 | return value |
| 494 | }) |
| 495 | scopedFixturePromiseCache.set(fixture, promise) |
| 496 | return promise |
| 497 | } |
| 498 | |
| 499 | async function resolveFixtureFunction( |
| 500 | fixtureFn: ( |
no test coverage detected