From 1c45ec6db14727792f9ee125b1f7c73bd8f62c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= Date: Tue, 23 Jul 2024 02:39:26 -0400 Subject: [PATCH] test: update exit code determination --- __test__/index.spec.ts | 8 +++++--- __test__/options.spec.ts | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/__test__/index.spec.ts b/__test__/index.spec.ts index 797713a..aaeba3a 100644 --- a/__test__/index.spec.ts +++ b/__test__/index.spec.ts @@ -32,14 +32,16 @@ test('run command', (t) => { test('run help', (t) => { const result = spawnSync('node', [`examples/simple.cjs`, '--help']) - t.falsy(result.error) + t.is(result.error, undefined) + t.is(result.stderr.length, 0) t.deepEqual(result.status ?? 0, 0) }) test('run version', (t) => { const version = spawnSync('node', [`examples/simple.cjs`, '--version']) const no_version = spawnSync('node', [`examples/no_version.cjs`, '--version']) - t.falsy(version.error) + t.is(version.error, undefined) + t.is(version.stderr.length, 0) t.deepEqual(version.status ?? 0, 0) - t.not(no_version.status ?? 0, 0) + t.not(no_version.stderr.length, 0) }) diff --git a/__test__/options.spec.ts b/__test__/options.spec.ts index c04db72..114448f 100644 --- a/__test__/options.spec.ts +++ b/__test__/options.spec.ts @@ -25,9 +25,10 @@ test('positional option', (t) => { test('required positional option', (t) => { const result = spawnSync('node', [`examples/positional_required.cjs`, 'foo']) const should_fail = spawnSync('node', [`examples/positional_required.cjs`]) - t.falsy(result.error) + t.is(result.error, undefined) + t.is(result.stderr.length, 0) t.deepEqual(result.status ?? 0, 0) - t.not(should_fail.status ?? 0, 0) + t.not(should_fail.stderr.length, 0) }) test('boolean flag', (t) => { @@ -57,4 +58,3 @@ test('boolean flag', (t) => { run(main, ['node', 'test.js']) }) }) -