-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfixtures6.ts
31 lines (26 loc) · 1003 Bytes
/
fixtures6.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { test as base, Page } from '@playwright/test'
import * as account from './services/account'
type Fixtures = {
auth: {
page: Page,
user: any,
token: any,
}
}
export const test = base.extend<Fixtures>({
auth: async ({ page }, use, workerInfo) => {
const baseURL = workerInfo.project.use.baseURL ?? "not set in project"
const credential = account.generateRandomCredential()
const { user, token } = await account.createAuthorizedUser(credential)
console.log(credential)
await page.goto('/login')
await page.context().addCookies([
{ url: baseURL, name: 'userName', value: credential.userName },
{ url: baseURL, name: 'userID', value: user.userID },
{ url: baseURL, name: 'token', value: token.token },
{ url: baseURL, name: 'expires', value: token.expires },
])
await use({ page, user, token })
},
})
export { expect } from '@playwright/test'