-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.ts
46 lines (43 loc) · 1.29 KB
/
index.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { ServiceAccount } from 'firebase-admin'
import type { FirebaseOptions } from 'firebase/app'
import type {
TestType,
PlaywrightTestArgs,
PlaywrightTestOptions,
PlaywrightWorkerArgs,
PlaywrightWorkerOptions
} from '@playwright/test'
import { Authentication } from './plugin/Authentication.js'
export type Credentials = {
auth: Authentication
UID: string
serviceAccount: ServiceAccount
options: FirebaseOptions
}
export interface AuthenticationParams {
UID: string
options: FirebaseOptions
serviceAccount: ServiceAccount
version: string
}
export default function playwrightFirebasePlugin(
serviceAccount: ServiceAccount,
options: FirebaseOptions,
UID: string,
base: TestType<
PlaywrightTestArgs & PlaywrightTestOptions,
PlaywrightWorkerArgs & PlaywrightWorkerOptions
>,
version = '10.5.0'
) {
return base.extend<{ auth: Authentication } & AuthenticationParams>({
UID: [UID, { option: true }],
serviceAccount: [serviceAccount, { option: true }],
options: [options, { option: true }],
version: [version, { option: true }],
auth: (
{ UID, options, serviceAccount, version }: AuthenticationParams,
use: (authentication: Authentication) => Promise<void>
) => use(new Authentication(UID, options, serviceAccount, version))
})
}