woocommerce/tests/bin/e2e-test-integration.js

47 lines
1.0 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
2019-12-15 22:34:35 +00:00
const { spawnSync } = require( 'child_process' );
const program = require( 'commander' );
2020-01-16 17:43:12 +00:00
const { useJestPuppeteerConfig } = require( 'puppeteer-utils' );
program
.usage( '<file ...> [options]' )
.option( '--dev', 'Development mode' )
.parse( process.argv );
const testEnvVars = {
NODE_ENV: 'test:e2e',
JEST_PUPPETEER_CONFIG: 'tests/e2e-tests/config/jest-puppeteer.config.js',
NODE_CONFIG_DIR: 'tests/e2e-tests/config',
};
if ( program.dev ) {
2020-01-16 17:43:12 +00:00
testEnvVars.PUPPETEER_HEADLESS = 'false';
testEnvVars.PUPPETEER_SLOWMO = '50';
delete testEnvVars.JEST_PUPPETEER_CONFIG;
useJestPuppeteerConfig();
}
const envVars = Object.assign( {}, process.env, testEnvVars );
2019-12-15 22:34:35 +00:00
let jestProcess = spawnSync(
'jest',
[
'--maxWorkers=1',
'--config=tests/e2e-tests/config/jest.config.js',
'--rootDir=./',
'--verbose',
program.args,
],
{
stdio: 'inherit',
env: envVars,
}
);
2019-12-15 22:34:35 +00:00
console.log( 'Jest exit code: ' + jestProcess.status );
// Pass Jest exit code to npm
process.exit( jestProcess.status );