From 66bcc2bc6436b544900cfbceb4bbfb0d93973490 Mon Sep 17 00:00:00 2001 From: Michael Solomon Date: Fri, 16 Jun 2023 17:07:37 +0300 Subject: [PATCH] fix: don't exit when no tests on initial run --- packages/testwatch/index.js | 3 +-- packages/testwatch/tests/index.test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/testwatch/index.js b/packages/testwatch/index.js index 4f67683..3b1c393 100755 --- a/packages/testwatch/index.js +++ b/packages/testwatch/index.js @@ -220,8 +220,7 @@ ${Object.entries(this.#currentCommands) } async run() { - await this.#runTests(); - await once(this.#emitter, 'drained'); + await Promise.all([once(this.#emitter, 'drained'), this.#runTests()]); this.#emitter.on('drained', () => this.#compactHelp()); this.#help(); for await (const data of on(process.stdin, 'data')) { diff --git a/packages/testwatch/tests/index.test.js b/packages/testwatch/tests/index.test.js index 310fac8..bbc600e 100644 --- a/packages/testwatch/tests/index.test.js +++ b/packages/testwatch/tests/index.test.js @@ -156,6 +156,17 @@ describe('testwatch', { concurrency: true, skip: !isSupported ? 'unsupported nod }); describe('files filter', () => { + it('should not exit if no test found on first run', async () => { + const { outputs, stderr } = await spawnInteractive('q', ['notexist']); + const activeFilters = '\nActive Filters: file name **/notexist*.*\n'; + const notFound = '\nNo files found for pattern **/notexist*.*'; + assert.strictEqual(stderr, ''); + assert.deepStrictEqual(outputs, [ + '', + `${notFound}\n${activeFilters}${mainMenuWithFilters}\n`, + ]); + }); + it('should set first argument as file filter', async () => { const { outputs, stderr } = await spawnInteractive('q', ['ind']); const activeFilters = '\nActive Filters: file name **/ind*.*\n';