Use new puppeteer-utils package.

This commit is contained in:
Brent Sessions 2020-01-16 10:43:12 -07:00 committed by Julia Amosova
parent c3d5b36474
commit 256d6f7808
5 changed files with 1551 additions and 121 deletions

1606
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -61,6 +61,7 @@
"node-sass": "4.13.0",
"prettier": "github:automattic/calypso-prettier#c56b4251",
"puppeteer": "2.0.0",
"puppeteer-utils": "github:Automattic/puppeteer-utils#65dedc2",
"stylelint": "12.0.1",
"stylelint-config-wordpress": "16.0.0",
"wp-textdomain": "^1.0.1"

View File

@ -2,6 +2,7 @@
const { spawnSync } = require( 'child_process' );
const program = require( 'commander' );
const { useJestPuppeteerConfig } = require( 'puppeteer-utils' );
program
.usage( '<file ...> [options]' )
@ -15,7 +16,11 @@ const testEnvVars = {
};
if ( program.dev ) {
testEnvVars.JEST_PUPPETEER_CONFIG = 'tests/e2e-tests/config/jest-puppeteer.dev.config.js';
testEnvVars.PUPPETEER_HEADLESS = 'false';
testEnvVars.PUPPETEER_SLOWMO = '50';
delete testEnvVars.JEST_PUPPETEER_CONFIG;
useJestPuppeteerConfig();
}
const envVars = Object.assign( {}, process.env, testEnvVars );

View File

@ -1,20 +0,0 @@
/** @format */
module.exports = {
launch: {
slowMo: process.env.PUPPETEER_SLOWMO ? false : 50,
headless: process.env.PUPPETEER_HEADLESS || false,
ignoreHTTPSErrors: true,
args: [
'--window-size=1920,1080',
'--user-agent=puppeteer-debug',
],
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',
}
};

View File

@ -1,34 +1,14 @@
/**
* @flow strict
* @format
* External dependencies
*/
const { jestConfig } = require( 'puppeteer-utils' );
const modifiedConfig = jestConfig;
const afterEnvSetup = modifiedConfig.setupFilesAfterEnv;
// https://jestjs.io/docs/en/configuration.html
afterEnvSetup.push( '<rootDir>/tests/e2e-tests/config/jest.setup.js');
modifiedConfig.setupFilesAfterEnv = afterEnvSetup;
module.exports = {
// Automatically clear mock calls and instances between every test
clearMocks: true,
// Sort test path alphabetically. This is needed so that `activate-and-setup` tests run first
modifiedConfig.testSequencer = '<rootDir>/tests/e2e-tests/config/jest-custom-sequencer.js';
// An array of file extensions your modules use
moduleFileExtensions: [ 'js' ],
preset: 'jest-puppeteer',
// Where to look for test files
roots: [ '<rootDir>/tests/e2e-tests/specs' ],
//setupFiles: [ '<rootDir>/.node_modules/regenerator-runtime/runtime' ],
// A list of paths to modules that run some code to configure or set up the testing framework
// before each test
setupFilesAfterEnv: [
'<rootDir>/tests/e2e-tests/config/jest.setup.js',
'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>/tests/e2e-tests/config/jest-custom-sequencer.js',
};
module.exports = modifiedConfig;