use @automattic/puppeteer-utils
This commit is contained in:
parent
e78beaf569
commit
d9e9faaa44
|
@ -5,6 +5,7 @@ const program = require( 'commander' );
|
|||
const path = require( 'path' );
|
||||
const fs = require( 'fs' );
|
||||
const getAppPath = require( '../utils/app-root' );
|
||||
const { JEST_PUPPETEER_CONFIG } = process.env;
|
||||
|
||||
program
|
||||
.usage( '<file ...> [options]' )
|
||||
|
@ -23,16 +24,18 @@ if ( appPath ) {
|
|||
);
|
||||
}
|
||||
|
||||
const testEnvVars = {
|
||||
let testEnvVars = {
|
||||
NODE_ENV: 'test-e2e',
|
||||
JEST_PUPPETEER_CONFIG: path.resolve(
|
||||
__dirname,
|
||||
'../config/jest-puppeteer.config.js'
|
||||
),
|
||||
NODE_CONFIG_DIR: nodeConfigDirs.join( ':' ),
|
||||
node_config_dev: program.dev ? 'yes' : 'no',
|
||||
jest_test_timeout: program.dev ? 120000 : 30000,
|
||||
};
|
||||
if ( ! JEST_PUPPETEER_CONFIG ) {
|
||||
testEnvVars.JEST_PUPPETEER_CONFIG = path.resolve(
|
||||
__dirname,
|
||||
'../config/jest-puppeteer.config.js'
|
||||
);
|
||||
}
|
||||
|
||||
let jestCommand = 'jest';
|
||||
const jestArgs = [
|
||||
|
|
|
@ -9,7 +9,8 @@ DELAY_SEC=10
|
|||
# Counter for the loop that checks if the Docker container had been built
|
||||
count=0
|
||||
WP_BASE_URL=$(node utils/get-base-url.js)
|
||||
echo "Testing URL: $WP_BASE_URL"
|
||||
printf "Testing URL: $WP_BASE_URL\n\n"
|
||||
|
||||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${WP_BASE_URL}/?pagename=ready)" != "200" ]]
|
||||
|
||||
do
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"url": "http://localhost:8085/",
|
||||
"url": "http://localhost:8084/",
|
||||
"users": {
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
|
|
|
@ -1,28 +1,21 @@
|
|||
/** @format */
|
||||
const { jestPuppeteerConfig } = require( '@automattic/puppeteer-utils' );
|
||||
|
||||
let puppeteerConfig;
|
||||
|
||||
if ( 'no' == global.process.env.node_config_dev ) {
|
||||
puppeteerConfig = {
|
||||
launch: {
|
||||
// Required for the logged out and logged in tests so they don't share app state/token.
|
||||
browserContext: 'incognito',
|
||||
},
|
||||
};
|
||||
puppeteerConfig = jestPuppeteerConfig;
|
||||
} else {
|
||||
puppeteerConfig = {
|
||||
launch: {
|
||||
slowMo: process.env.PUPPETEER_SLOWMO ? false : 50,
|
||||
headless: process.env.PUPPETEER_HEADLESS || false,
|
||||
...jestPuppeteerConfig.launch,
|
||||
ignoreHTTPSErrors: true,
|
||||
args: [ '--window-size=1920,1080', '--user-agent=chrome' ],
|
||||
devtools: true,
|
||||
defaultViewport: {
|
||||
width: 1280,
|
||||
height: 800,
|
||||
},
|
||||
// Required for the logged out and logged in tests so they don't share app state/token.
|
||||
browserContext: 'incognito',
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
const { jestConfig } = require( '@automattic/puppeteer-utils' );
|
||||
|
||||
module.exports = {
|
||||
// Automatically clear mock calls and instances between every test
|
||||
clearMocks: true,
|
||||
|
||||
// An array of file extensions your modules use
|
||||
moduleFileExtensions: [ 'js' ],
|
||||
|
||||
...jestConfig,
|
||||
moduleNameMapper: {
|
||||
'@woocommerce/e2e-tests/(.*)':
|
||||
'<rootDir>/tests/e2e/$1',
|
||||
},
|
||||
|
||||
preset: 'jest-puppeteer',
|
||||
|
||||
setupFiles: [ '<rootDir>/config/env.setup.js' ],
|
||||
// A list of paths to modules that run some code to configure or set up the testing framework
|
||||
// before each test
|
||||
|
@ -20,12 +15,13 @@ module.exports = {
|
|||
'expect-puppeteer',
|
||||
],
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
testMatch: [ '**/*.(test|spec).js' ],
|
||||
// Sort test path alphabetically. This is needed so that `activate-and-setup` tests run first
|
||||
testSequencer: '<rootDir>/config/jest-custom-sequencer.js',
|
||||
// Set the test timeout in milliseconds.
|
||||
testTimeout: parseInt( global.process.env.jest_test_timeout ),
|
||||
|
||||
transformIgnorePatterns: [ 'node_modules/(?!(woocommerce)/)' ],
|
||||
transformIgnorePatterns: [
|
||||
...jestConfig.transformIgnorePatterns,
|
||||
'node_modules/(?!(woocommerce)/)'
|
||||
],
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue