@@ -5,10 +5,10 @@ require('../lib/worker/options').set({chalkOptions: {level: 0}});
55const { test} = require ( 'tap' ) ;
66const delay = require ( 'delay' ) ;
77const ContextRef = require ( '../lib/context-ref' ) ;
8- const { withExperiments } = require ( './helper/ava-test' ) ;
8+ const { newAva } = require ( './helper/ava-test' ) ;
99
1010test ( 'try-commit works' , async t => {
11- const ava = withExperiments ( { tryAssertion : true } ) ;
11+ const ava = newAva ( ) ;
1212 const instance = ava ( async a => {
1313 const res = await a . try ( b => b . pass ( ) ) ;
1414 t . true ( res . passed ) ;
@@ -22,7 +22,7 @@ test('try-commit works', async t => {
2222} ) ;
2323
2424test ( 'try-commit is bound' , async t => {
25- const ava = withExperiments ( { tryAssertion : true } ) ;
25+ const ava = newAva ( ) ;
2626 const result = await ava ( async a => {
2727 const { try : tryFn } = a ;
2828 const res = await tryFn ( b => b . pass ( ) ) ;
@@ -33,7 +33,7 @@ test('try-commit is bound', async t => {
3333} ) ;
3434
3535test ( 'try-commit discards failed attempt' , async t => {
36- const ava = withExperiments ( { tryAssertion : true } ) ;
36+ const ava = newAva ( ) ;
3737 const result = await ava ( async a => {
3838 const res = await a . try ( b => b . fail ( ) ) ;
3939 await res . discard ( ) ;
@@ -44,7 +44,7 @@ test('try-commit discards failed attempt', async t => {
4444} ) ;
4545
4646test ( 'try-commit can discard produced result' , async t => {
47- const ava = withExperiments ( { tryAssertion : true } ) ;
47+ const ava = newAva ( ) ;
4848 const result = await ava ( async a => {
4949 const res = await a . try ( b => b . pass ( ) ) ;
5050 res . discard ( ) ;
@@ -57,7 +57,7 @@ test('try-commit can discard produced result', async t => {
5757} ) ;
5858
5959test ( 'try-commit fails when not all assertions were committed/discarded' , async t => {
60- const ava = withExperiments ( { tryAssertion : true } ) ;
60+ const ava = newAva ( ) ;
6161 const result = await ava ( async a => {
6262 a . pass ( ) ;
6363 await a . try ( b => b . pass ( ) ) ;
@@ -73,7 +73,7 @@ test('try-commit works with values', async t => {
7373 const testValue1 = 123 ;
7474 const testValue2 = 123 ;
7575
76- const ava = withExperiments ( { tryAssertion : true } ) ;
76+ const ava = newAva ( ) ;
7777 const result = await ava ( async a => {
7878 const res = await a . try ( ( b , val1 , val2 ) => {
7979 b . is ( val1 , val2 ) ;
@@ -86,7 +86,7 @@ test('try-commit works with values', async t => {
8686} ) ;
8787
8888test ( 'try-commit is properly counted' , async t => {
89- const ava = withExperiments ( { tryAssertion : true } ) ;
89+ const ava = newAva ( ) ;
9090 const instance = ava ( async a => {
9191 const res = await a . try ( b => {
9292 b . is ( 1 , 1 ) ;
@@ -107,7 +107,7 @@ test('try-commit is properly counted', async t => {
107107} ) ;
108108
109109test ( 'try-commit is properly counted multiple' , async t => {
110- const ava = withExperiments ( { tryAssertion : true } ) ;
110+ const ava = newAva ( ) ;
111111 const instance = ava ( async a => {
112112 const [ res1 , res2 , res3 ] = await Promise . all ( [
113113 a . try ( b => b . pass ( ) ) ,
@@ -130,7 +130,7 @@ test('try-commit is properly counted multiple', async t => {
130130
131131test ( 'try-commit goes as many levels' , async t => {
132132 t . plan ( 5 ) ;
133- const ava = withExperiments ( { tryAssertion : true } ) ;
133+ const ava = newAva ( ) ;
134134 const instance = ava ( async a => {
135135 t . ok ( a . try ) ;
136136 const res1 = await a . try ( async b => {
@@ -151,7 +151,7 @@ test('try-commit goes as many levels', async t => {
151151} ) ;
152152
153153test ( 'try-commit fails when not committed' , async t => {
154- const ava = withExperiments ( { tryAssertion : true } ) ;
154+ const ava = newAva ( ) ;
155155 const result = await ava ( async a => {
156156 const res = await a . try ( b => b . pass ( ) ) ;
157157 t . true ( res . passed ) ;
@@ -164,7 +164,7 @@ test('try-commit fails when not committed', async t => {
164164} ) ;
165165
166166test ( 'try-commit fails when no assertions inside try' , async t => {
167- const ava = withExperiments ( { tryAssertion : true } ) ;
167+ const ava = newAva ( ) ;
168168 const result = await ava ( async a => {
169169 const res = await a . try ( ( ) => { } ) ;
170170 t . false ( res . passed ) ;
@@ -180,7 +180,7 @@ test('try-commit fails when no assertions inside try', async t => {
180180} ) ;
181181
182182test ( 'try-commit fails when no assertions inside multiple try' , async t => {
183- const ava = withExperiments ( { tryAssertion : true } ) ;
183+ const ava = newAva ( ) ;
184184 const result = await ava ( async a => {
185185 const [ res1 , res2 ] = await Promise . all ( [
186186 a . try ( b => b . pass ( ) ) ,
@@ -203,7 +203,7 @@ test('try-commit fails when no assertions inside multiple try', async t => {
203203} ) ;
204204
205205test ( 'test fails when try-commit committed to failed state' , async t => {
206- const ava = withExperiments ( { tryAssertion : true } ) ;
206+ const ava = newAva ( ) ;
207207 const result = await ava ( async a => {
208208 const res = await a . try ( b => b . fail ( ) ) ;
209209 t . false ( res . passed ) ;
@@ -215,7 +215,7 @@ test('test fails when try-commit committed to failed state', async t => {
215215
216216test ( 'try-commit has proper titles, when going in depth and width' , async t => {
217217 t . plan ( 6 ) ;
218- const ava = withExperiments ( { tryAssertion : true } ) ;
218+ const ava = newAva ( ) ;
219219 await ava ( async a => {
220220 t . is ( a . title , 'test' ) ;
221221
@@ -235,7 +235,7 @@ test('try-commit has proper titles, when going in depth and width', async t => {
235235} ) ;
236236
237237test ( 'try-commit does not fail when calling commit twice' , async t => {
238- const ava = withExperiments ( { tryAssertion : true } ) ;
238+ const ava = newAva ( ) ;
239239 const result = await ava ( async a => {
240240 const res = await a . try ( b => b . pass ( ) ) ;
241241 res . commit ( ) ;
@@ -247,7 +247,7 @@ test('try-commit does not fail when calling commit twice', async t => {
247247} ) ;
248248
249249test ( 'try-commit does not fail when calling discard twice' , async t => {
250- const ava = withExperiments ( { tryAssertion : true } ) ;
250+ const ava = newAva ( ) ;
251251 const result = await ava ( async a => {
252252 const res = await a . try ( b => b . pass ( ) ) ;
253253 res . discard ( ) ;
@@ -261,7 +261,7 @@ test('try-commit does not fail when calling discard twice', async t => {
261261} ) ;
262262
263263test ( 'try-commit allows planning inside the try' , async t => {
264- const ava = withExperiments ( { tryAssertion : true } ) ;
264+ const ava = newAva ( ) ;
265265 const result = await ava ( async a => {
266266 const res = await a . try ( b => {
267267 b . plan ( 3 ) ;
@@ -278,7 +278,7 @@ test('try-commit allows planning inside the try', async t => {
278278} ) ;
279279
280280test ( 'try-commit fails when plan is not reached inside the try' , async t => {
281- const ava = withExperiments ( { tryAssertion : true } ) ;
281+ const ava = newAva ( ) ;
282282 const result = await ava ( async a => {
283283 const res = await a . try ( b => {
284284 b . plan ( 3 ) ;
@@ -294,7 +294,7 @@ test('try-commit fails when plan is not reached inside the try', async t => {
294294} ) ;
295295
296296test ( 'plan within try-commit is not affected by assertions outside' , async t => {
297- const ava = withExperiments ( { tryAssertion : true } ) ;
297+ const ava = newAva ( ) ;
298298 const result = await ava ( async a => {
299299 a . is ( 1 , 1 ) ;
300300 a . is ( 2 , 2 ) ;
@@ -314,7 +314,7 @@ test('plan within try-commit is not affected by assertions outside', async t =>
314314} ) ;
315315
316316test ( 'assertions within try-commit do not affect plan in the parent test' , async t => {
317- const ava = withExperiments ( { tryAssertion : true } ) ;
317+ const ava = newAva ( ) ;
318318 const result = await ava ( async a => {
319319 a . plan ( 2 ) ;
320320
@@ -335,7 +335,7 @@ test('assertions within try-commit do not affect plan in the parent test', async
335335} ) ;
336336
337337test ( 'test expected to fail will pass with failing try-commit within the test' , async t => {
338- const ava = withExperiments ( { tryAssertion : true } ) ;
338+ const ava = newAva ( ) ;
339339 const result = await ava . failing ( async a => {
340340 const res = await a . try ( b => b . fail ( ) ) ;
341341 t . false ( res . passed ) ;
@@ -351,7 +351,7 @@ test('test expected to fail will pass with failing try-commit within the test',
351351} ) ;
352352
353353test ( 'try-commit works with callback test' , async t => {
354- const ava = withExperiments ( { tryAssertion : true } ) ;
354+ const ava = newAva ( ) ;
355355 const result = await ava . cb ( a => {
356356 a
357357 . try ( b => b . pass ( ) )
@@ -365,7 +365,7 @@ test('try-commit works with callback test', async t => {
365365} ) ;
366366
367367test ( 'try-commit works with failing callback test' , async t => {
368- const ava = withExperiments ( { tryAssertion : true } ) ;
368+ const ava = newAva ( ) ;
369369 const result = await ava . cb . failing ( a => {
370370 a
371371 . try ( b => b . fail ( ) )
@@ -387,7 +387,7 @@ test('try-commit works with failing callback test', async t => {
387387} ) ;
388388
389389test ( 'try-commit does not allow to use .end() in attempt when parent is callback test' , async t => {
390- const ava = withExperiments ( { tryAssertion : true } ) ;
390+ const ava = newAva ( ) ;
391391 const result = await ava . cb ( a => {
392392 a
393393 . try ( b => {
@@ -408,7 +408,7 @@ test('try-commit does not allow to use .end() in attempt when parent is callback
408408} ) ;
409409
410410test ( 'try-commit does not allow to use .end() in attempt when parent is regular test' , async t => {
411- const ava = withExperiments ( { tryAssertion : true } ) ;
411+ const ava = newAva ( ) ;
412412 const result = await ava ( async a => {
413413 const res = await a . try ( b => {
414414 b . pass ( ) ;
@@ -433,7 +433,7 @@ test('try-commit accepts macros', async t => {
433433
434434 macro . title = ( providedTitle = '' ) => `${ providedTitle } Title` . trim ( ) ;
435435
436- const ava = withExperiments ( { tryAssertion : true } ) ;
436+ const ava = newAva ( ) ;
437437 const result = await ava ( async a => {
438438 const res = await a . try ( macro ) ;
439439 t . true ( res . passed ) ;
@@ -444,7 +444,7 @@ test('try-commit accepts macros', async t => {
444444} ) ;
445445
446446test ( 'try-commit accepts multiple macros' , async t => {
447- const ava = withExperiments ( { tryAssertion : true } ) ;
447+ const ava = newAva ( ) ;
448448 const result = await ava ( async a => {
449449 const [ res1 , res2 ] = await a . try ( [
450450 b => {
@@ -481,7 +481,7 @@ test('try-commit accepts multiple macros', async t => {
481481} ) ;
482482
483483test ( 'try-commit returns results in the same shape as when implementations are passed' , async t => {
484- const ava = withExperiments ( { tryAssertion : true } ) ;
484+ const ava = newAva ( ) ;
485485 const result = await ava ( async a => {
486486 const [ res1 , res2 , res3 ] = await Promise . all ( [
487487 a . try ( b => b . pass ( ) ) ,
@@ -506,7 +506,7 @@ test('try-commit returns results in the same shape as when implementations are p
506506} ) ;
507507
508508test ( 'try-commit abides timeout' , async t => {
509- const ava = withExperiments ( { tryAssertion : true } ) ;
509+ const ava = newAva ( ) ;
510510 const result1 = await ava ( async a => {
511511 a . timeout ( 10 ) ;
512512 const result = await a . try ( async b => {
@@ -521,7 +521,7 @@ test('try-commit abides timeout', async t => {
521521} ) ;
522522
523523test ( 'try-commit fails when it exceeds its own timeout' , async t => {
524- const ava = withExperiments ( { tryAssertion : true } ) ;
524+ const ava = newAva ( ) ;
525525 const result = await ava ( async a => {
526526 a . timeout ( 200 ) ;
527527 const result = await a . try ( async b => {
@@ -545,7 +545,7 @@ test('try-commit fails when it exceeds its own timeout', async t => {
545545} ) ;
546546
547547test ( 'try-commit refreshes the timeout on commit/discard' , async t => {
548- const ava = withExperiments ( { tryAssertion : true } ) ;
548+ const ava = newAva ( ) ;
549549 const result1 = await ava . cb ( a => {
550550 a . timeout ( 100 ) ;
551551 a . plan ( 3 ) ;
@@ -559,7 +559,7 @@ test('try-commit refreshes the timeout on commit/discard', async t => {
559559} ) ;
560560
561561test ( 'assertions within try-commit do not refresh the timeout' , async t => {
562- const ava = withExperiments ( { tryAssertion : true } ) ;
562+ const ava = newAva ( ) ;
563563 const result = await ava ( async a => {
564564 a . timeout ( 15 ) ;
565565 a . pass ( ) ;
@@ -587,7 +587,7 @@ test('try-commit inherits the test context', async t => {
587587 const context = new ContextRef ( ) ;
588588 const data = { foo : 'bar' } ;
589589 context . set ( data ) ;
590- const ava = withExperiments ( { tryAssertion : true } ) ;
590+ const ava = newAva ( ) ;
591591 const result = await ava ( async a => {
592592 const res = await a . try ( b => {
593593 b . pass ( ) ;
@@ -603,7 +603,7 @@ test('assigning context in try-commit does not affect parent', async t => {
603603 const context = new ContextRef ( ) ;
604604 const data = { foo : 'bar' } ;
605605 context . set ( data ) ;
606- const ava = withExperiments ( { tryAssertion : true } ) ;
606+ const ava = newAva ( ) ;
607607 const result = await ava ( async a => {
608608 t . strictDeepEqual ( a . context , data ) ;
609609 const res = await a . try ( b => {
@@ -618,7 +618,7 @@ test('assigning context in try-commit does not affect parent', async t => {
618618} ) ;
619619
620620test ( 'do not run assertions outside of an active attempt' , async t => {
621- const ava = withExperiments ( { tryAssertion : true } ) ;
621+ const ava = newAva ( ) ;
622622 const passing = await ava ( async a => {
623623 await a . try ( ( ) => { } ) ;
624624 a . pass ( ) ;
0 commit comments