Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 27, 2019
1 parent 9f37f05 commit c9b9790
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/helpers/testing/ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ const { stubStackTrace } = require('../stack')

stubStackTrace()

const { name, ...options } = JSON.parse(OPTIONS)
const { name, message, ...options } = JSON.parse(OPTIONS)
// Functions cannot be serialized in JSON
const messageA = message === undefined ? message : () => message

if (options.register) {
// eslint-disable-next-line import/no-dynamic-require
require(REGISTER_PATH)
} else {
logProcessErrors(options)
logProcessErrors({ ...options, message: messageA })
}

test(`should make tests fail on ${name}`, t => {
Expand Down
105 changes: 105 additions & 0 deletions test/options/snapshots/testing.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ Generated by [AVA](https://ava.li).
1 test passed`,
}

## [ava] [multipleResolves] should allow overriding options not specified by runner

> Snapshot 1
{
code: 1,
stderr: '',
stdout: `√ should make tests fail on multipleResolves␊
Uncaught exception in build/test/options/ava.js␊
Error: test message␊
× build/test/options/ava.js exited with a non-zero exit code: 1␊
1 test passed␊
1 uncaught exception`,
}

## [ava] [multipleResolves] should make tests fails

> Snapshot 1
Expand Down Expand Up @@ -79,6 +99,32 @@ Generated by [AVA](https://ava.li).
1 unhandled rejection`,
}

## [ava] [rejectionHandled] should allow overriding options not specified by runner

> Snapshot 1
{
code: 1,
stderr: '',
stdout: `√ should make tests fail on rejectionHandled␊
Unhandled rejection in build/test/options/ava.js␊
Error: message␊
Uncaught exception in build/test/options/ava.js␊
Error: test message␊
× build/test/options/ava.js exited with a non-zero exit code: 1␊
1 test passed␊
1 unhandled rejection␊
1 uncaught exception`,
}

## [ava] [rejectionHandled] should make tests fails

> Snapshot 1
Expand Down Expand Up @@ -135,6 +181,26 @@ Generated by [AVA](https://ava.li).

## [ava] [uncaughtException] should allow overriding 'opts.level'

> Snapshot 1
{
code: 1,
stderr: '',
stdout: `√ should make tests fail on uncaughtException␊
Uncaught exception in build/test/options/ava.js␊
Error: message␊
× build/test/options/ava.js exited with a non-zero exit code: 1␊
1 test passed␊
1 uncaught exception`,
}

## [ava] [uncaughtException] should allow overriding options not specified by runner

> Snapshot 1
{
Expand Down Expand Up @@ -195,6 +261,25 @@ Generated by [AVA](https://ava.li).

## [ava] [unhandledRejection] should allow overriding 'opts.level'

> Snapshot 1
{
code: 1,
stderr: '',
stdout: `√ should make tests fail on unhandledRejection␊
Unhandled rejection in build/test/options/ava.js␊
Error: message␊
1 test passed␊
1 unhandled rejection`,
}

## [ava] [unhandledRejection] should allow overriding options not specified by runner

> Snapshot 1
{
Expand Down Expand Up @@ -262,6 +347,26 @@ Generated by [AVA](https://ava.li).
1 test passed`,
}

## [ava] [warning] should allow overriding options not specified by runner

> Snapshot 1
{
code: 1,
stderr: '',
stdout: `√ should make tests fail on warning␊
Uncaught exception in build/test/options/ava.js␊
Error: test message␊
× build/test/options/ava.js exited with a non-zero exit code: 1␊
1 test passed␊
1 uncaught exception`,
}

## [ava] [warning] should make tests fails

> Snapshot 1
Expand Down
Binary file modified test/options/snapshots/testing.js.snap
Binary file not shown.
9 changes: 9 additions & 0 deletions test/options/testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ repeatEventsRunners((prefix, testing, { name }) => {
t.snapshot(returnValue)
})

test(`${prefix} should allow overriding options not specified by runner`, async t => {
const returnValue = await callRunner(
{ testing, name },
{ message: 'test message' },
)

t.snapshot(returnValue)
})

test(`${prefix} should work with the -r flag`, async t => {
const returnValue = await callRunner({ testing, name }, { register: true })

Expand Down

0 comments on commit c9b9790

Please sign in to comment.