Skip to content

Commit

Permalink
test: update exit code determination
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 committed Jul 23, 2024
1 parent b9d6f28 commit 1c45ec6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions __test__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
6 changes: 3 additions & 3 deletions __test__/options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -57,4 +58,3 @@ test('boolean flag', (t) => {
run(main, ['node', 'test.js'])
})
})

0 comments on commit 1c45ec6

Please sign in to comment.