-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathsetup-performance-test.js
51 lines (45 loc) · 1.39 KB
/
setup-performance-test.js
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
47
48
49
50
51
/**
* WordPress dependencies
*/
import {
activatePlugin,
clearLocalStorage,
enablePageDialogAccept,
setBrowserViewport,
trashAllPosts,
} from '@wordpress/e2e-test-utils';
/**
* Timeout, in seconds, that the test should be allowed to run.
*
* @type {string|undefined}
*/
const PUPPETEER_TIMEOUT = process.env.PUPPETEER_TIMEOUT;
// The Jest timeout is increased because these tests are a bit slow.
jest.setTimeout( PUPPETEER_TIMEOUT || 100000 );
async function setupPage() {
await setBrowserViewport( 'large' );
await page.emulateMediaFeatures( [
{ name: 'prefers-reduced-motion', value: 'reduce' },
] );
}
// Before every test suite run, delete all content created by the test. This
// ensures other posts/comments/etc. aren't dirtying tests and tests don't
// depend on each other's side-effects.
beforeAll( async () => {
enablePageDialogAccept();
await trashAllPosts();
await trashAllPosts( 'wp_block' );
await activatePlugin( 'gutenberg-test-plugin-disables-the-css-animations' );
await clearLocalStorage();
await setupPage();
} );
afterEach( async () => {
// Clear localStorage between tests so that the next test starts clean.
await clearLocalStorage();
// Close the previous page entirely and create a new page, so that the next
// test isn't affected by page unload work.
await page.close();
page = await browser.newPage();
// Set up testing config on new page.
await setupPage();
} );