From 0ad1ad7aec58b8df1a4e62db882b35fe4bfebb9e Mon Sep 17 00:00:00 2001 From: Nikita Skovoroda Date: Wed, 10 Jul 2024 17:50:28 +0300 Subject: [PATCH] feat: --watch mode Closes: https://github.com/ExodusMovement/test/issues/5 --- README.md | 2 ++ bin/index.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2697119..a70aa2e 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ Just use `"test": "exodus-test"` - `--coverage-engine node` -- use Node.js builtint coverage engine +- `--watch` -- operate in watch mode and re-run tests on file changes + - `--passWithNoTests` -- do not error when no test files were found - `--write-snapshots` -- write snapshots instead of verifying them (has `--test-update-snapshots` alias) diff --git a/bin/index.js b/bin/index.js index 6ccb7fd..526d7bb 100755 --- a/bin/index.js +++ b/bin/index.js @@ -26,9 +26,10 @@ function parseOptions() { esbuild: false, babel: false, coverage: false, + coverageEngine: 'c8', // c8 or node + watch: false, passWithNoTests: false, writeSnapshots: false, - coverageEngine: 'c8', // c8 or node } const args = [...process.argv] @@ -63,6 +64,9 @@ function parseOptions() { case '--coverage': options.coverage = true break + case '--watch': + options.watch = true + break case '--passWithNoTests': options.passWithNoTests = true break @@ -120,6 +124,11 @@ if (options.forceExit) { args.push('--test-force-exit') } +if (options.watch) { + assert((major === 18 && minor > 13) || major >= 20, 'For watch mode, use Node.js >= 18.13.0') + args.push('--watch') +} + if (options.coverage) { if (options.coverageEngine === 'node') { args.push('--experimental-test-coverage')