From 61e8b0fad4d3ad6dee2354fbe9b657813ae5f7cf Mon Sep 17 00:00:00 2001 From: Gustavo Henke Date: Wed, 3 Apr 2024 00:01:02 +1100 Subject: [PATCH] bin: improve tests for version flag In preparation for #418 --- bin/concurrently.spec.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/concurrently.spec.ts b/bin/concurrently.spec.ts index c0b2e1bb..3cbb400f 100644 --- a/bin/concurrently.spec.ts +++ b/bin/concurrently.spec.ts @@ -117,10 +117,16 @@ it('has help command', async () => { }); describe('has version command', () => { + const pkg = fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'); + const { version } = JSON.parse(pkg); + it.each(['--version', '-V', '-v'])('%s', async (arg) => { - const exit = await run(arg).exit; + const child = run(arg); + const log = await child.getLogLines(); + expect(log).toContain(version); - expect(exit.code).toBe(0); + const { code } = await child.exit; + expect(code).toBe(0); }); });