Skip to content

Commit c9b9790

Browse files
committed
Add test
1 parent 9f37f05 commit c9b9790

File tree

4 files changed

+118
-2
lines changed

4 files changed

+118
-2
lines changed

test/helpers/testing/ava.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ const { stubStackTrace } = require('../stack')
1414

1515
stubStackTrace()
1616

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

1921
if (options.register) {
2022
// eslint-disable-next-line import/no-dynamic-require
2123
require(REGISTER_PATH)
2224
} else {
23-
logProcessErrors(options)
25+
logProcessErrors({ ...options, message: messageA })
2426
}
2527

2628
test(`should make tests fail on ${name}`, t => {

test/options/snapshots/testing.js.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ Generated by [AVA](https://ava.li).
1616
1 test passed`,
1717
}
1818

19+
## [ava] [multipleResolves] should allow overriding options not specified by runner
20+
21+
> Snapshot 1
22+
23+
{
24+
code: 1,
25+
stderr: '',
26+
stdout: `√ should make tests fail on multipleResolves␊
27+
28+
Uncaught exception in build/test/options/ava.js␊
29+
30+
31+
Error: test message␊
32+
33+
× build/test/options/ava.js exited with a non-zero exit code: 1␊
34+
35+
1 test passed␊
36+
1 uncaught exception`,
37+
}
38+
1939
## [ava] [multipleResolves] should make tests fails
2040

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

102+
## [ava] [rejectionHandled] should allow overriding options not specified by runner
103+
104+
> Snapshot 1
105+
106+
{
107+
code: 1,
108+
stderr: '',
109+
stdout: `√ should make tests fail on rejectionHandled␊
110+
111+
Unhandled rejection in build/test/options/ava.js␊
112+
113+
114+
Error: message␊
115+
116+
Uncaught exception in build/test/options/ava.js␊
117+
118+
119+
Error: test message␊
120+
121+
× build/test/options/ava.js exited with a non-zero exit code: 1␊
122+
123+
1 test passed␊
124+
1 unhandled rejection␊
125+
1 uncaught exception`,
126+
}
127+
82128
## [ava] [rejectionHandled] should make tests fails
83129

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

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

184+
> Snapshot 1
185+
186+
{
187+
code: 1,
188+
stderr: '',
189+
stdout: `√ should make tests fail on uncaughtException␊
190+
191+
Uncaught exception in build/test/options/ava.js␊
192+
193+
194+
Error: message␊
195+
196+
× build/test/options/ava.js exited with a non-zero exit code: 1␊
197+
198+
1 test passed␊
199+
1 uncaught exception`,
200+
}
201+
202+
## [ava] [uncaughtException] should allow overriding options not specified by runner
203+
138204
> Snapshot 1
139205
140206
{
@@ -195,6 +261,25 @@ Generated by [AVA](https://ava.li).
195261

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

264+
> Snapshot 1
265+
266+
{
267+
code: 1,
268+
stderr: '',
269+
stdout: `√ should make tests fail on unhandledRejection␊
270+
271+
Unhandled rejection in build/test/options/ava.js␊
272+
273+
274+
Error: message␊
275+
276+
277+
1 test passed␊
278+
1 unhandled rejection`,
279+
}
280+
281+
## [ava] [unhandledRejection] should allow overriding options not specified by runner
282+
198283
> Snapshot 1
199284
200285
{
@@ -262,6 +347,26 @@ Generated by [AVA](https://ava.li).
262347
1 test passed`,
263348
}
264349

350+
## [ava] [warning] should allow overriding options not specified by runner
351+
352+
> Snapshot 1
353+
354+
{
355+
code: 1,
356+
stderr: '',
357+
stdout: `√ should make tests fail on warning␊
358+
359+
Uncaught exception in build/test/options/ava.js␊
360+
361+
362+
Error: test message␊
363+
364+
× build/test/options/ava.js exited with a non-zero exit code: 1␊
365+
366+
1 test passed␊
367+
1 uncaught exception`,
368+
}
369+
265370
## [ava] [warning] should make tests fails
266371

267372
> Snapshot 1
160 Bytes
Binary file not shown.

test/options/testing.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ repeatEventsRunners((prefix, testing, { name }) => {
2222
t.snapshot(returnValue)
2323
})
2424

25+
test(`${prefix} should allow overriding options not specified by runner`, async t => {
26+
const returnValue = await callRunner(
27+
{ testing, name },
28+
{ message: 'test message' },
29+
)
30+
31+
t.snapshot(returnValue)
32+
})
33+
2534
test(`${prefix} should work with the -r flag`, async t => {
2635
const returnValue = await callRunner({ testing, name }, { register: true })
2736

0 commit comments

Comments
 (0)