Fix auth.setup.ts to properly create storage state
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
+8
-5
@@ -1,5 +1,4 @@
|
||||
import { test as setup } from '@playwright/test';
|
||||
import { request } from '@playwright/test';
|
||||
import { test as setup, request } from '@playwright/test';
|
||||
|
||||
setup('authenticate', async ({ page }) => {
|
||||
const token = process.env.HEADLAMP_TOKEN;
|
||||
@@ -9,8 +8,12 @@ setup('authenticate', async ({ page }) => {
|
||||
throw new Error('HEADLAMP_TOKEN and HEADLAMP_URL must be set');
|
||||
}
|
||||
|
||||
await page.context().addInitScript(() => {
|
||||
window.localStorage.setItem('token', 'dummy-token');
|
||||
});
|
||||
|
||||
await page.goto(url);
|
||||
await page.evaluate((t) => {
|
||||
localStorage.setItem('token', t);
|
||||
}, token);
|
||||
|
||||
const context = page.context();
|
||||
await context.storageState({ path: 'e2e/.auth/state.json' });
|
||||
});
|
||||
Reference in New Issue
Block a user