@@ -2,15 +2,25 @@ const Test = require('../../lib/test');
2
2
const ContextRef = require ( '../../lib/context-ref' ) ;
3
3
4
4
function withExperiments ( experiments = { } ) {
5
- function ava ( fn , contextRef ) {
5
+ const uniqueTestTitles = new Set ( ) ;
6
+ const registerUniqueTitle = title => {
7
+ if ( uniqueTestTitles . has ( title ) ) {
8
+ return false ;
9
+ }
10
+
11
+ uniqueTestTitles . add ( title ) ;
12
+ return true ;
13
+ } ;
14
+
15
+ function ava ( fn , contextRef , title = 'test' ) {
6
16
return new Test ( {
7
17
contextRef : contextRef || new ContextRef ( ) ,
8
18
experiments,
9
19
failWithoutAssertions : true ,
10
20
fn,
11
- registerUniqueTitle : ( ) => true ,
21
+ registerUniqueTitle,
12
22
metadata : { type : 'test' , callback : false } ,
13
- title : 'test'
23
+ title
14
24
} ) ;
15
25
}
16
26
@@ -20,7 +30,7 @@ function withExperiments(experiments = {}) {
20
30
experiments,
21
31
failWithoutAssertions : true ,
22
32
fn,
23
- registerUniqueTitle : ( ) => true ,
33
+ registerUniqueTitle,
24
34
metadata : { type : 'test' , callback : false , failing : true } ,
25
35
title : 'test.failing'
26
36
} ) ;
@@ -32,7 +42,7 @@ function withExperiments(experiments = {}) {
32
42
experiments,
33
43
failWithoutAssertions : true ,
34
44
fn,
35
- registerUniqueTitle : ( ) => true ,
45
+ registerUniqueTitle,
36
46
metadata : { type : 'test' , callback : true } ,
37
47
title : 'test.cb'
38
48
} ) ;
@@ -44,7 +54,7 @@ function withExperiments(experiments = {}) {
44
54
experiments,
45
55
failWithoutAssertions : true ,
46
56
fn,
47
- registerUniqueTitle : ( ) => true ,
57
+ registerUniqueTitle,
48
58
metadata : { type : 'test' , callback : true , failing : true } ,
49
59
title : 'test.cb.failing'
50
60
} ) ;
0 commit comments