1 | # Installation
|
2 | > `npm install --save @types/jest-environment-puppeteer`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for jest-environment-puppeteer (https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest-environment-puppeteer.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest-environment-puppeteer/index.d.ts)
|
10 | ````ts
|
11 | // Type definitions for jest-environment-puppeteer 5.0
|
12 | // Project: https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer
|
13 | // Definitions by: Ifiok Jr. <https://github.com/ifiokjr>
|
14 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
15 | // TypeScript Version: 3.8
|
16 |
|
17 | import NodeEnvironment = require('jest-environment-node');
|
18 | import { Browser, Page, BrowserContext } from 'puppeteer';
|
19 | import { Context } from 'vm';
|
20 |
|
21 | interface JestPuppeteer {
|
22 | /**
|
23 | * Reset global.page
|
24 | *
|
25 | * ```ts
|
26 | * beforeEach(async () => {
|
27 | * await jestPuppeteer.resetPage()
|
28 | * })
|
29 | * ```
|
30 | */
|
31 | resetPage(): Promise<void>;
|
32 |
|
33 | /**
|
34 | * Reset global.browser
|
35 | *
|
36 | * ```ts
|
37 | * beforeEach(async () => {
|
38 | * await jestPuppeteer.resetBrowser()
|
39 | * })
|
40 | * ```
|
41 | */
|
42 | resetBrowser(): Promise<void>;
|
43 |
|
44 | /**
|
45 | * Suspends test execution and gives you opportunity to see what's going on in the browser
|
46 | * - Jest is suspended (no timeout)
|
47 | * - A debugger instruction to Chromium, if Puppeteer has been launched with { devtools: true } it will stop
|
48 | *
|
49 | * ```ts
|
50 | * it('should put test in debug mode', async () => {
|
51 | * await jestPuppeteer.debug()
|
52 | * })
|
53 | * ```
|
54 | */
|
55 | debug(): Promise<void>;
|
56 | }
|
57 |
|
58 | interface Global extends NonNullable<NodeEnvironment['global']> {
|
59 | browser: Browser;
|
60 | context: Context;
|
61 | page: Page;
|
62 | jestPuppeteer: JestPuppeteer;
|
63 | }
|
64 |
|
65 | /** Note: TestEnvironment is sandboxed. Each test suite will trigger setup/teardown in their own TestEnvironment. */
|
66 | declare class PuppeteerEnvironment extends NodeEnvironment {
|
67 | global: Global;
|
68 | }
|
69 |
|
70 | declare global {
|
71 | const browser: Browser;
|
72 | const context: BrowserContext;
|
73 | const page: Page;
|
74 | const jestPuppeteer: JestPuppeteer;
|
75 | }
|
76 |
|
77 | export = PuppeteerEnvironment;
|
78 |
|
79 | ````
|
80 |
|
81 | ### Additional Details
|
82 | * Last updated: Wed, 02 Nov 2022 21:02:56 GMT
|
83 | * Dependencies: [@types/jest-environment-node](https://npmjs.com/package/@types/jest-environment-node), [@types/puppeteer](https://npmjs.com/package/@types/puppeteer)
|
84 | * Global values: none
|
85 |
|
86 | # Credits
|
87 | These definitions were written by [Ifiok Jr.](https://github.com/ifiokjr).
|
88 |
|
\ | No newline at end of file |