Skip to content

Commit 1c5a0af

Browse files
committed
Authentication added
1 parent 087a55f commit 1c5a0af

File tree

4 files changed

+17
-41
lines changed

4 files changed

+17
-41
lines changed

playwright.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export default defineConfig({
1717
projects: [
1818
{
1919
name: 'setup',
20-
testMatch: './tests/playwright/auth-setup.ts',
20+
testMatch: 'tests/playwright/auth.setup.ts',
2121
},
2222
{
2323
name: 'chromium',
2424
use: {
2525
...devices['Desktop Chrome'],
26-
storageState: './tests/playwright/.auth/storageState.json'
26+
storageState: 'tests/playwright/.auth/user.json',
2727
},
2828
dependencies: ['setup'],
2929
},

tests/playwright/auth-setup.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/playwright/auth.setup.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { test as setup } from '@playwright/test';
2+
import dotenv from 'dotenv';
3+
4+
const authFile = 'tests/playwright/.auth/user.json';
5+
6+
setup('authenticate', async ({ request }) => {
7+
dotenv.config({ path: 'tests/playwright/.env.local' });
8+
await request.post('https://msls.co/wp-login.php', {
9+
form: {
10+
'log': 'user',
11+
'pwd': 'password'
12+
}
13+
});
14+
await request.storageState({ path: authFile });
15+
});
File renamed without changes.

0 commit comments

Comments
 (0)