summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gascou-Vaillancourt <paul.gascvail@gmail.com>2019-06-12 11:34:20 -0400
committerPaul Gascou-Vaillancourt <paul.gascvail@gmail.com>2019-06-12 20:27:49 -0400
commit0bf22dca1a550761b5e0bd8a1458cd78414e4959 (patch)
treeeef15d5800504a4c447fb6fe3f1d9d6c05db7280
parent26e88e876fd54cea6f71ba6f4ab117336401a6a2 (diff)
downloadgitlab-ce-0bf22dca1a550761b5e0bd8a1458cd78414e4959.tar.gz
Add watch option to test script
-rwxr-xr-xscripts/frontend/test.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/frontend/test.js b/scripts/frontend/test.js
index dab7176f8c1..5dab97648ed 100755
--- a/scripts/frontend/test.js
+++ b/scripts/frontend/test.js
@@ -16,8 +16,14 @@ program
.version('0.1.0')
.usage('[options] <file ...>')
.option('-p, --parallel', 'Run tests suites in parallel')
+ .option(
+ '-w, --watch',
+ 'Rerun tests when files change (tests will be run in parallel if this enabled)',
+ )
.parse(process.argv);
+const shouldParalleslize = program.parallel || program.watch;
+
const isSuccess = code => code === SUCCESS_CODE;
const combineExitCodes = codes => {
@@ -31,7 +37,7 @@ const skipIfFail = fn => code => (isSuccess(code) ? fn() : code);
const endWithEOL = str => (str[str.length - 1] === '\n' ? str : `${str}${EOL}`);
const runTests = paths => {
- if (program.parallel) {
+ if (shouldParalleslize) {
return Promise.all([runJest(paths), runKarma(paths)]).then(combineExitCodes);
} else {
return runJest(paths).then(skipIfFail(() => runKarma(paths)));
@@ -96,6 +102,10 @@ const toKarmaArgs = paths =>
paths.reduce((acc, path) => acc.concat('-f', replacePathForKarma(path)), []);
const main = paths => {
+ if (program.watch) {
+ JEST_ARGS.push('--watch');
+ KARMA_ARGS.push('--single-run', 'false', '--auto-watch');
+ }
runTests(paths).then(code => {
console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
if (isSuccess(code)) {