2020-08-04 22:55:13 +00:00
|
|
|
/**
|
|
|
|
* External Dependencies
|
|
|
|
*/
|
2020-07-28 19:23:32 +00:00
|
|
|
const { jestConfig } = require( '@automattic/puppeteer-utils' );
|
2020-08-04 22:55:13 +00:00
|
|
|
const path = require( 'path' );
|
|
|
|
const fs = require( 'fs' );
|
2020-04-02 13:41:06 +00:00
|
|
|
|
2020-08-04 22:55:13 +00:00
|
|
|
/**
|
|
|
|
* Internal Dependencies
|
|
|
|
*/
|
|
|
|
const { getAppRoot } = require( '../utils' );
|
|
|
|
|
|
|
|
let setupFilesAfterEnv = [
|
|
|
|
path.resolve( __dirname, '../build/setup/jest.setup.js' ),
|
|
|
|
'expect-puppeteer',
|
|
|
|
];
|
|
|
|
|
|
|
|
const appPath = getAppRoot();
|
|
|
|
const localJestSetupFile = path.resolve( appPath, 'tests/e2e/config/jest.setup.js' );
|
|
|
|
if (fs.existsSync( localJestSetupFile ) ) {
|
|
|
|
setupFilesAfterEnv.push( localJestSetupFile );
|
|
|
|
}
|
2020-10-01 18:56:02 +00:00
|
|
|
|
|
|
|
let combinedConfig = {
|
2020-07-28 19:23:32 +00:00
|
|
|
...jestConfig,
|
2020-04-02 13:41:06 +00:00
|
|
|
moduleNameMapper: {
|
|
|
|
'@woocommerce/e2e-tests/(.*)':
|
2020-05-11 18:45:32 +00:00
|
|
|
'<rootDir>/tests/e2e/$1',
|
2020-04-02 13:41:06 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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
|
2020-08-04 22:55:13 +00:00
|
|
|
setupFilesAfterEnv,
|
2020-04-02 13:41:06 +00:00
|
|
|
|
|
|
|
// Sort test path alphabetically. This is needed so that `activate-and-setup` tests run first
|
|
|
|
testSequencer: '<rootDir>/config/jest-custom-sequencer.js',
|
2020-05-05 16:56:00 +00:00
|
|
|
// Set the test timeout in milliseconds.
|
|
|
|
testTimeout: parseInt( global.process.env.jest_test_timeout ),
|
2020-04-02 13:41:06 +00:00
|
|
|
|
2020-07-28 19:23:32 +00:00
|
|
|
transformIgnorePatterns: [
|
|
|
|
...jestConfig.transformIgnorePatterns,
|
|
|
|
'node_modules/(?!(woocommerce)/)'
|
|
|
|
],
|
2020-04-02 13:41:06 +00:00
|
|
|
};
|
2020-10-01 18:56:02 +00:00
|
|
|
|
|
|
|
if ( process.env.jest_test_spec ) {
|
|
|
|
combinedConfig.testMatch = [
|
|
|
|
process.env.jest_test_spec
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = combinedConfig;
|