allow running named test files that don't match test spec pattern

This commit is contained in:
Ron Rennick 2020-10-01 15:56:02 -03:00
parent 8910357437
commit 5139c73029
2 changed files with 22 additions and 1 deletions

View File

@ -40,6 +40,18 @@ if ( ! JEST_PUPPETEER_CONFIG ) {
testEnvVars.JEST_PUPPETEER_CONFIG = fs.existsSync( localJestConfigFile ) ? localJestConfigFile : jestConfigFile;
}
// Check for running a specific script
if ( program.args.length == 1 ) {
// Check for both absolute and relative paths
const testSpecAbs = path.resolve( program.args[0] )
const testSpecRel = path.resolve( appPath, program.args[0] );
if ( fs.existsSync( testSpecAbs ) ) {
process.env.jest_test_spec = testSpecAbs;
} else if ( fs.existsSync( testSpecRel ) ) {
process.env.jest_test_spec = testSpecRel;
}
}
let jestCommand = 'jest';
const jestArgs = [
'--maxWorkers=1',

View File

@ -20,7 +20,8 @@ const localJestSetupFile = path.resolve( appPath, 'tests/e2e/config/jest.setup.j
if (fs.existsSync( localJestSetupFile ) ) {
setupFilesAfterEnv.push( localJestSetupFile );
}
module.exports = {
let combinedConfig = {
...jestConfig,
moduleNameMapper: {
'@woocommerce/e2e-tests/(.*)':
@ -42,3 +43,11 @@ module.exports = {
'node_modules/(?!(woocommerce)/)'
],
};
if ( process.env.jest_test_spec ) {
combinedConfig.testMatch = [
process.env.jest_test_spec
];
}
module.exports = combinedConfig;