From 21bad6b974ba59b42e2f79b2126a10ea25f149e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 2 Jun 2019 21:27:48 +0200 Subject: [PATCH 1/2] ability to inject particular testfile to yarn test --- bin/test.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/test.js b/bin/test.js index 42e1a473..6a5107ae 100644 --- a/bin/test.js +++ b/bin/test.js @@ -18,8 +18,16 @@ const args = [ './lib/**/*test.js' ]; -cp.spawnSync(path.resolve(__dirname, '../node_modules/.bin/mocha'), args, { - cwd: path.resolve(__dirname, '..'), - env, - stdio: 'inherit' -}); +// ability to inject particular test files via +// yarn test [testFileA testFileB ...] +const testFilesFromArgs = process.argv.slice(2); + +cp.spawnSync( + path.resolve(__dirname, '../node_modules/.bin/mocha'), + (testFilesFromArgs.length) ? testFilesFromArgs : args, + { + cwd: path.resolve(__dirname, '..'), + env, + stdio: 'inherit' + } +); From 9b6e182bf6bd4b5e73266d51065a9e529bf4b575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Sun, 2 Jun 2019 21:38:24 +0200 Subject: [PATCH 2/2] simplify arg handling --- bin/test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/test.js b/bin/test.js index 6a5107ae..2cdd1b3b 100644 --- a/bin/test.js +++ b/bin/test.js @@ -10,7 +10,7 @@ const path = require('path'); const env = { ...process.env }; env.NODE_PATH = path.resolve(__dirname, '../out'); -const args = [ +let testFiles = [ './out/*test.js', './out/**/*test.js', './out/*integration.js', @@ -20,11 +20,13 @@ const args = [ // ability to inject particular test files via // yarn test [testFileA testFileB ...] -const testFilesFromArgs = process.argv.slice(2); +if (process.argv.length > 2) { + testFiles = process.argv.slice(2); +} cp.spawnSync( path.resolve(__dirname, '../node_modules/.bin/mocha'), - (testFilesFromArgs.length) ? testFilesFromArgs : args, + testFiles, { cwd: path.resolve(__dirname, '..'), env,