Skip to content

Commit 9d36023

Browse files
committed
better fix for playwright issue
1 parent aa1184a commit 9d36023

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

tests/e2e/example.test.e2e.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ test('login', async ({page}, workerInfo) => {
4545

4646
test('logged in user', async ({browser}, workerInfo) => {
4747
const context = await load_logged_in_context(browser, workerInfo, 'user2');
48-
if (!context) return;
49-
5048
const page = await context.newPage();
5149
await page.goto('/');
5250

tests/e2e/utils_e2e.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ export async function login_user(browser: Browser, workerInfo: WorkerInfo, user:
3333
}
3434

3535
export async function load_logged_in_context(browser: Browser, workerInfo: WorkerInfo, user: string) {
36-
let context;
3736
try {
38-
context = await browser.newContext({storageState: `${ARTIFACTS_PATH}/state-${user}-${workerInfo.workerIndex}.json`});
37+
return await browser.newContext({storageState: `${ARTIFACTS_PATH}/state-${user}-${workerInfo.workerIndex}.json`});
3938
} catch (err) {
4039
if (err.code === 'ENOENT') {
4140
throw new Error(`Could not find state for '${user}'. Did you call login_user(browser, workerInfo, '${user}') in test.beforeAll()?`);
41+
} else {
42+
throw err;
4243
}
4344
}
44-
return context;
4545
}
4646

4747
export async function save_visual(page: Page) {

0 commit comments

Comments
 (0)