mirror of
git://develop.git.wordpress.org/
synced 2025-02-24 00:24:52 +01:00
As per the migration plan shared last year, this migrates all browser-based tests in WordPress core to use Playwright. This includes end-to-end, performance, and visual regression tests. Props swissspidy, mamaduka, kevin940726, bartkalisz, desrosj, adamsilverstein. Fixes #59517. git-svn-id: https://develop.svn.wordpress.org/trunk@56926 602fd350-edb4-49c9-b593-d223f7449a82
41 lines
910 B
JavaScript
41 lines
910 B
JavaScript
/**
|
|
* External dependencies
|
|
*/
|
|
import { request } from '@playwright/test';
|
|
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
import { RequestUtils } from '@wordpress/e2e-test-utils-playwright';
|
|
|
|
/**
|
|
*
|
|
* @param {import('@playwright/test').FullConfig} config
|
|
* @returns {Promise<void>}
|
|
*/
|
|
async function globalSetup( config ) {
|
|
const { storageState, baseURL } = config.projects[ 0 ].use;
|
|
const storageStatePath =
|
|
typeof storageState === 'string' ? storageState : undefined;
|
|
|
|
const requestContext = await request.newContext( {
|
|
baseURL,
|
|
} );
|
|
|
|
const requestUtils = new RequestUtils( requestContext, {
|
|
storageStatePath,
|
|
} );
|
|
|
|
// Authenticate and save the storageState to disk.
|
|
await requestUtils.setupRest();
|
|
|
|
// Reset the test environment before running the tests.
|
|
await Promise.all( [
|
|
requestUtils.activateTheme( 'twentytwentyone' ),
|
|
] );
|
|
|
|
await requestContext.dispose();
|
|
}
|
|
|
|
export default globalSetup;
|