Skip to content

Commit 6eeb967

Browse files
committed
chore: move global vars to top of file, specify wait time in error msg
1 parent 3360944 commit 6eeb967

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

testing/e2e/src/helpers/fixtures.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import type { NavigateVariadicArgs, ProjectAuth, ProjectMetadata, RouteTo } from
1515

1616
type PageModels = typeof pageModels;
1717

18+
const MAX_WAIT_MS = 30_000;
19+
const POLL_INTERVAL_MS = 200;
20+
1821
type TestArgs = {
1922
getPageModel: <TKey extends Extract<keyof PageModels, RouteTo>>(
2023
key: TKey,
@@ -58,16 +61,17 @@ export const test = base.extend<TestArgs, WorkerArgs>({
5861
return use(async () => {
5962
const authStorageFile = getProjectMetadata('authStorageFile');
6063
// Wait for auth file to exist with timeout
61-
const MAX_WAIT_MS = 30_000;
62-
const POLL_INTERVAL_MS = 200;
64+
6365
const maxAttempts = MAX_WAIT_MS / POLL_INTERVAL_MS;
6466
let attempts = 0;
6567
while (!fs.existsSync(authStorageFile) && attempts < maxAttempts) {
6668
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
6769
attempts++;
6870
}
6971
if (!fs.existsSync(authStorageFile)) {
70-
throw new Error(`Cannot get project auth: storage file does not exist after waiting: ${authStorageFile}`);
72+
throw new Error(
73+
`Cannot get project auth: storage file does not exist after waiting 30000ms: ${authStorageFile}`
74+
);
7175
}
7276
return JSON.parse(await fs.promises.readFile(authStorageFile, 'utf8')) as ProjectAuth;
7377
});

0 commit comments

Comments
 (0)