@@ -36,7 +36,11 @@ declare global {
3636 name ?: string ,
3737 properties ?: unknown
3838 ) : void ;
39- function async_test ( func : TestFn , name ?: string , properties ?: unknown ) : void ;
39+ function async_test (
40+ func : TestFn | string ,
41+ name ?: string ,
42+ properties ?: unknown
43+ ) : Test ;
4044 function test ( func : TestFn , name ?: string , properties ?: unknown ) : void ;
4145}
4246
@@ -293,15 +297,38 @@ class AsyncTest extends Test {
293297 }
294298}
295299
296- globalThis . async_test = ( func , name , properties ) : void => {
297- if ( maybeAddSkippedTest ( name ?? '' ) ) {
298- return ;
300+ globalThis . async_test = ( func , name , properties ) : Test => {
301+ // async_test can be called in two ways:
302+ // 1. async_test(func, name, properties) - func is a TestFn
303+ // 2. async_test(name, properties) - just creates a test with the given name
304+ let testName : string ;
305+ let testFunc : TestFn | undefined ;
306+
307+ if ( typeof func === 'string' ) {
308+ // async_test(name, properties) signature
309+ testName = func ;
310+ testFunc = undefined ;
311+ // name parameter is actually properties in this case
312+ properties = name ;
313+ } else {
314+ // async_test(func, name, properties) signature
315+ testName = name ?? '' ;
316+ testFunc = func ;
299317 }
300318
301- const testCase = new AsyncTest ( name ?? '' , properties ) ;
319+ if ( maybeAddSkippedTest ( testName ) ) {
320+ // Return a dummy test object for skipped tests
321+ return new SkippedTest ( testName , 'DISABLED' ) ;
322+ }
323+
324+ const testCase = new AsyncTest ( testName , properties ) ;
302325 globalThis . state . subtests . push ( testCase ) ;
303326
304- testCase . step ( func , testCase , testCase ) ;
327+ if ( testFunc ) {
328+ testCase . step ( testFunc , testCase , testCase ) ;
329+ }
330+
331+ return testCase ;
305332} ;
306333
307334/**
0 commit comments