UNPKG

1.86 kBTypeScriptView Raw
1import type { Page, Browser, BrowserContext } from 'playwright-core'
2import type { SkipOption } from '../src/types'
3
4interface JestPlaywright {
5 skip: (skipOptions: SkipOption, callback: Function) => void
6 /**
7 * Reset global.page
8 *
9 * ```ts
10 * it('should reset page', async () => {
11 * await jestPlaywright.resetPage()
12 * })
13 * ```
14 */
15 resetPage: () => Promise<void>
16 /**
17 * Reset global.context
18 *
19 * ```ts
20 * it('should reset context', async () => {
21 * await jestPlaywright.resetContext()
22 * })
23 * ```
24 */
25 resetContext: () => Promise<void>
26 /**
27 * Reset global.browser, global.context, and global.page
28 *
29 * ```ts
30 * it('should reset page', async () => {
31 * await jestPlaywright.resetBrowser()
32 * })
33 * ```
34 */
35 resetBrowser: () => Promise<void>
36 /**
37 * Suspends test execution and gives you opportunity to see what's going on in the browser
38 * - Jest is suspended (no timeout)
39 * - A debugger instruction to the Browser, if Playwright has been launched with { devtools: true } it will stop
40 *
41 * ```ts
42 * it('should put test in debug mode', async () => {
43 * await jestPlaywright.debug()
44 * })
45 * ```
46 */
47 debug: () => Promise<void>
48 /**
49 * Saves the coverage to the disk which will only work if `collectCoverage`
50 * in `jest-playwright.config.js` file is set to true. The merged coverage file
51 * is then available in `.nyc_output/coverage.json`. Mostly its needed in the
52 * `afterEach` handler like that:
53 *
54 * ```ts
55 * afterEach(async () => {
56 * await jestPlaywright.saveCoverage(page)
57 * })
58 * ```
59 */
60 saveCoverage: (page: Page) => Promise<void>
61}
62
63declare global {
64 const browserName: string
65 const deviceName: string | null
66 const page: Page
67 const browser: Browser
68 const context: BrowserContext
69 const jestPlaywright: JestPlaywright
70}