|
1 | 1 | import { vi, expect } from "vitest"; |
2 | 2 |
|
3 | | -// Prevent @solidjs/testing-library from auto-cleaning the DOM between steps. |
4 | | -// vitest-cucumber maps each Given/When/Then to a separate test(), so the DOM |
5 | | -// must persist across steps within a scenario. Cleanup is done manually in |
6 | | -// AfterEachScenario instead. |
| 3 | +// vitest-cucumber maps each Given/When/Then to a separate test(). The DOM must |
| 4 | +// persist across steps within a scenario, but @solidjs/testing-library registers |
| 5 | +// afterEach(cleanup) at import time — vi.hoisted ensures the env var is set |
| 6 | +// BEFORE that import evaluates. Manual cleanup in AfterEachScenario replaces it. |
7 | 7 | vi.hoisted(() => { |
8 | 8 | process.env.STL_SKIP_AUTO_CLEANUP = "true"; |
9 | 9 | }); |
10 | | -import type { RepoEntry } from "../../../src/app/services/api"; |
| 10 | +import type { RepoEntry, OrgEntry } from "../../../src/app/services/api"; |
11 | 11 |
|
12 | 12 | // Mock getClient before importing component |
13 | 13 | const mockRequest = vi.fn().mockResolvedValue({ data: {} }); |
@@ -75,14 +75,12 @@ function getAccordionOrder(orgNames: string[]): string[] { |
75 | 75 | } |
76 | 76 |
|
77 | 77 | // ── State shared across steps within a scenario ─────────────────────────────── |
78 | | -type OrgEntry = { login: string; avatarUrl: string; type: "user" | "org" }; |
79 | | -let setSelectedOrgs: (orgs: string[]) => void; |
80 | | -let setOrgEntries: (entries: OrgEntry[]) => void; |
| 78 | +let setSelectedOrgs: (orgs: string[]) => void = () => {}; |
| 79 | +let setOrgEntries: (entries: OrgEntry[]) => void = () => {}; |
81 | 80 |
|
82 | 81 | describeFeature(feature, ({ Scenario, Background, BeforeEachScenario, AfterEachScenario }) => { |
83 | 82 | BeforeEachScenario(() => { |
84 | 83 | vi.clearAllMocks(); |
85 | | - vi.restoreAllMocks(); |
86 | 84 | mockRequest.mockResolvedValue({ data: {} }); |
87 | 85 | vi.mocked(api.fetchOrgs).mockResolvedValue([]); |
88 | 86 | vi.mocked(api.discoverUpstreamRepos).mockResolvedValue([]); |
|
0 commit comments