Skip to content

Commit

Permalink
test: improved error messages for parseArguments provides opts.require
Browse files Browse the repository at this point in the history
using `t.test` for grouping the different assertions, so it's more clear what exactly fails
  • Loading branch information
karfau committed Jan 7, 2020
1 parent a883153 commit 0e9ae34
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/option-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ import { assertStdout, command } from '../test.command'
test('parseArguments provides opts.require', async t => {
[
'--require hook', '--require=hook', '-r hook', '-r=hook'
].forEach(option => {
].forEach(option => t.test(`when passing "${option}"`, async t =>
t.matches(
parseArguments(`${option} runnable`.split(' ')).opts,
{require: ['hook']},
`when passing "${option}"`
{require: ['hook']}
)
})
))

t.matches(
parseArguments([`runnable`]).opts,
{require: []},
`when --require option is not passed`
t.test(
'when --require option is not passed',
async t => t.matches(parseArguments([`runnable`]).opts, {require: []})
)

const modules = ['one', 'two']
const multiple = modules.map(m => `-r ${m}`).join(' ')
const actual = parseArguments(`${multiple} runnable`.split(' ')).opts
t.matches(actual, {require: modules}, `when passing "${multiple}"`)
t.test(`when passing "${multiple}"`, async t => t.matches(
parseArguments(`${multiple} runnable`.split(' ')).opts,
{require: modules}
))
})

test('requireRunnable requires from opts.require', async t => {
Expand Down

0 comments on commit 0e9ae34

Please sign in to comment.