2022-03-30 02:57:11 +00:00
|
|
|
require( 'dotenv' ).config();
|
2022-05-31 18:57:04 +00:00
|
|
|
const {
|
|
|
|
BASE_URL,
|
|
|
|
VERBOSE,
|
|
|
|
USE_INDEX_PERMALINKS,
|
|
|
|
DEFAULT_TIMEOUT_OVERRIDE,
|
|
|
|
} = process.env;
|
2021-08-24 01:25:07 +00:00
|
|
|
const verboseOutput = VERBOSE === 'true';
|
2022-05-31 18:57:04 +00:00
|
|
|
const { defaults } = require( 'jest-config' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override the default timeout, if specified.
|
|
|
|
* Useful when running API tests against an externally hosted test site.
|
|
|
|
*/
|
|
|
|
const testTimeoutOverride = DEFAULT_TIMEOUT_OVERRIDE
|
|
|
|
? Number( DEFAULT_TIMEOUT_OVERRIDE )
|
|
|
|
: defaults.testTimeout;
|
2021-08-23 17:39:03 +00:00
|
|
|
|
|
|
|
// Update the API path if the `USE_INDEX_PERMALINKS` flag is set
|
2021-08-24 01:25:07 +00:00
|
|
|
const useIndexPermalinks = USE_INDEX_PERMALINKS === 'true';
|
2022-03-30 02:57:11 +00:00
|
|
|
let apiPath = `${ BASE_URL }/?rest_route=/wc/v3/`;
|
2021-09-07 22:20:44 +00:00
|
|
|
if ( useIndexPermalinks ) {
|
2022-03-30 02:57:11 +00:00
|
|
|
apiPath = `${ BASE_URL }/wp-json/wc/v3/`;
|
2021-08-23 17:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
// Use the `jest-runner-groups` package.
|
2021-08-24 01:25:07 +00:00
|
|
|
runner: 'groups',
|
2021-08-23 17:39:03 +00:00
|
|
|
|
|
|
|
// A set of global variables that need to be available in all test environments
|
|
|
|
globals: {
|
2021-08-24 01:25:07 +00:00
|
|
|
API_PATH: apiPath,
|
2021-08-23 17:39:03 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Indicates whether each individual test should be reported during the run
|
|
|
|
verbose: verboseOutput,
|
2022-03-30 02:57:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure `jest-allure` for Jest v24 and above.
|
|
|
|
*
|
|
|
|
* @see https://www.npmjs.com/package/jest-allure#jest--v-24-
|
|
|
|
*/
|
|
|
|
setupFilesAfterEnv: [
|
|
|
|
'jest-allure/dist/setup',
|
|
|
|
'<rootDir>/allure.config.js',
|
|
|
|
],
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure Jest is using Jasmine as its test runner.
|
|
|
|
* `jest-allure` does not work with the `jest-circus` test runner, which is the default test runner of Jest starting from v27.
|
|
|
|
*
|
|
|
|
* @see https://github.com/zaqqaz/jest-allure#uses-jest-circus-or-jest--v-27-
|
|
|
|
*/
|
|
|
|
testRunner: 'jasmine2',
|
2022-05-31 18:57:04 +00:00
|
|
|
|
|
|
|
testTimeout: testTimeoutOverride,
|
2021-08-23 17:39:03 +00:00
|
|
|
};
|