Update test-unit to allow double dash args

This commit is contained in:
Leonardo Bressan Motyczka
2019-10-22 03:00:18 +00:00
parent 7576e8c202
commit 51ef0d0680
+11 -4
View File
@@ -15,15 +15,22 @@ let testFiles = [
'./out/**/*test.js' './out/**/*test.js'
]; ];
// ability to inject particular test files via let flagArgs = [];
// yarn test [testFileA testFileB ...]
if (process.argv.length > 2) { if (process.argv.length > 2) {
testFiles = process.argv.slice(2); const args = process.argv.slice(2);
flagArgs = args.filter(e => e.startsWith('--'));
// ability to inject particular test files via
// yarn test [testFileA testFileB ...]
files = args.filter(e => !e.startsWith('--'));
if(files.length){
testFiles = files;
}
} }
const run = cp.spawnSync( const run = cp.spawnSync(
path.resolve(__dirname, '../node_modules/.bin/mocha'), path.resolve(__dirname, '../node_modules/.bin/mocha'),
testFiles, [...testFiles, ...flagArgs],
{ {
cwd: path.resolve(__dirname, '..'), cwd: path.resolve(__dirname, '..'),
env, env,