Skip to content

Commit

Permalink
fix: don't exit when no tests on initial run
Browse files Browse the repository at this point in the history
  • Loading branch information
mikicho authored and MoLow committed Jun 19, 2023
1 parent 4357fbd commit 66bcc2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/testwatch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
11 changes: 11 additions & 0 deletions packages/testwatch/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 66bcc2b

Please sign in to comment.