@@ -123,6 +123,24 @@ Deno.test("beforeAll(), afterAll(), beforeEach() and afterEach()", async () => {
123123 assertSpyCalls ( afterEachFn , 2 ) ;
124124} ) ;
125125
126+ Deno . test ( "beforeAll() with it.only() propagates only to Deno.test" , ( ) => {
127+ using test = stub ( Deno , "test" ) ;
128+ try {
129+ beforeAll ( ( ) => { } ) ;
130+
131+ it ( { name : "a" , fn : ( ) => { } } ) ;
132+ it . only ( { name : "b" , fn : ( ) => { } } ) ;
133+ it ( { name : "c" , fn : ( ) => { } } ) ;
134+
135+ assertSpyCall ( test , 0 ) ;
136+ const options = test . calls [ 0 ] ?. args [ 0 ] as Deno . TestDefinition ;
137+ assertEquals ( Object . keys ( options ) . sort ( ) , [ "fn" , "name" , "only" ] ) ;
138+ assertObjectMatch ( options , { name : "global" , only : true } ) ;
139+ } finally {
140+ TestSuiteInternal . reset ( ) ;
141+ }
142+ } ) ;
143+
126144Deno . test ( "it()" , async ( t ) => {
127145 /**
128146 * Asserts that `Deno.test` is called with the correct options for the `it` call in the callback function.
@@ -1418,7 +1436,6 @@ Deno.test("describe()", async (t) => {
14181436 await t . step ( "flat child only" , async ( t ) => {
14191437 /**
14201438 * Asserts that when only is used on a child `describe` or `it` call, it will be the only test case or suite that runs within the top test suite.
1421- * This demonstrates the issue where `Deno.test` is called without `only` even though one of its child steps are focused.
14221439 * This is used to reduce code duplication when testing calling `describe.ignore` with different call signatures.
14231440 */
14241441 async function assertOnly (
@@ -1434,10 +1451,11 @@ Deno.test("describe()", async (t) => {
14341451 const options = call ?. args [ 0 ] as Deno . TestDefinition ;
14351452 assertEquals (
14361453 Object . keys ( options ) . sort ( ) ,
1437- [ "name" , "fn" ] . sort ( ) ,
1454+ [ "name" , "only" , " fn"] . sort ( ) ,
14381455 ) ;
14391456 assertObjectMatch ( options , {
14401457 name : "example" ,
1458+ only : true ,
14411459 } ) ;
14421460
14431461 assertSpyCalls ( fns [ 0 ] , 0 ) ;
0 commit comments