@@ -36,18 +36,50 @@ async function terminateOpenTransactions(client: MongoClient) {
36
36
}
37
37
}
38
38
39
+ export async function runUnifiedTest (
40
+ ctx : Mocha . Context ,
41
+ unifiedSuite : uni . UnifiedSuite ,
42
+ test : uni . Test
43
+ ) : Promise < void > ;
44
+
45
+ /**
46
+ * @deprecated use the overload that provides a function filter instead
47
+ */
39
48
export async function runUnifiedTest (
40
49
ctx : Mocha . Context ,
41
50
unifiedSuite : uni . UnifiedSuite ,
42
51
test : uni . Test ,
43
52
testsToSkip ?: string [ ]
53
+ ) : Promise < void > ;
54
+
55
+ /**
56
+ *
57
+ * @param skipFilter - a function that returns true if the test should be skipped
58
+ */
59
+ export async function runUnifiedTest (
60
+ ctx : Mocha . Context ,
61
+ unifiedSuite : uni . UnifiedSuite ,
62
+ test : uni . Test ,
63
+ skipFilter ?: ( test : uni . Test ) => boolean
64
+ ) : Promise < void > ;
65
+
66
+ export async function runUnifiedTest (
67
+ ctx : Mocha . Context ,
68
+ unifiedSuite : uni . UnifiedSuite ,
69
+ test : uni . Test ,
70
+ testsToSkipOrFilter ?: string [ ] | ( ( test : uni . Test ) => boolean )
44
71
) : Promise < void > {
45
72
// Some basic expectations we can catch early
46
73
expect ( test ) . to . exist ;
47
74
expect ( unifiedSuite ) . to . exist ;
48
75
expect ( ctx ) . to . exist ;
49
76
expect ( ctx . configuration ) . to . exist ;
50
77
78
+ if ( Array . isArray ( testsToSkipOrFilter ) ) {
79
+ const testsToSkip = testsToSkipOrFilter ;
80
+ testsToSkipOrFilter = ( test : uni . Test ) => testsToSkip . includes ( test . description ) ;
81
+ }
82
+
51
83
const schemaVersion = patchVersion ( unifiedSuite . schemaVersion ) ;
52
84
expect ( semverSatisfies ( schemaVersion , uni . SupportedVersion ) ) . to . be . true ;
53
85
@@ -58,7 +90,7 @@ export async function runUnifiedTest(
58
90
ctx . skip ( ) ;
59
91
}
60
92
61
- if ( testsToSkip ?. includes ( test . description ) ) {
93
+ if ( testsToSkipOrFilter ?. ( test ) ) {
62
94
ctx . skip ( ) ;
63
95
}
64
96
@@ -236,12 +268,35 @@ export async function runUnifiedTest(
236
268
}
237
269
}
238
270
239
- export function runUnifiedSuite ( specTests : uni . UnifiedSuite [ ] , testsToSkip ?: string [ ] ) : void {
271
+ export function runUnifiedSuite ( specTests : uni . UnifiedSuite [ ] ) : void ;
272
+
273
+ /**
274
+ * @deprecated use the overload that provides a function filter instead
275
+ */
276
+ export function runUnifiedSuite ( specTests : uni . UnifiedSuite [ ] , testsToSkip ?: string [ ] ) : void ;
277
+
278
+ /**
279
+ *
280
+ * @param skipFilter - a function that returns true if the test should be skipped
281
+ */
282
+ export function runUnifiedSuite (
283
+ specTests : uni . UnifiedSuite [ ] ,
284
+ skipFilter ?: ( test : uni . Test ) => boolean
285
+ ) : void ;
286
+
287
+ export function runUnifiedSuite (
288
+ specTests : uni . UnifiedSuite [ ] ,
289
+ testsToSkipOrFilter ?: string [ ] | ( ( test : uni . Test ) => boolean )
290
+ ) : void {
240
291
for ( const unifiedSuite of specTests ) {
241
292
context ( String ( unifiedSuite . description ) , function ( ) {
242
293
for ( const test of unifiedSuite . tests ) {
243
294
it ( String ( test . description ) , async function ( ) {
244
- await runUnifiedTest ( this , unifiedSuite , test , testsToSkip ) ;
295
+ if ( Array . isArray ( testsToSkipOrFilter ) ) {
296
+ await runUnifiedTest ( this , unifiedSuite , test , testsToSkipOrFilter ) ;
297
+ } else {
298
+ await runUnifiedTest ( this , unifiedSuite , test , testsToSkipOrFilter ) ;
299
+ }
245
300
} ) ;
246
301
}
247
302
} ) ;
0 commit comments