@@ -24,10 +24,20 @@ describe('test list command', () => {
2424
2525 expect ( logs ) . toMatchInlineSnapshot ( `
2626 [
27+ "a.test.ts > test a",
2728 "a.test.ts > test a > test a-1",
2829 "a.test.ts > test a-2",
30+ "b.test.ts > test b",
2931 "b.test.ts > test b > test b-1",
3032 "b.test.ts > test b-2",
33+ "c.test.ts > test c describe each 0",
34+ "c.test.ts > test c describe for 0",
35+ "c.test.ts > test c describe runIf",
36+ "c.test.ts > test c describe skipIf",
37+ "c.test.ts > test c it each 0",
38+ "c.test.ts > test c it for 0",
39+ "c.test.ts > test c it runIf",
40+ "c.test.ts > test c it skipIf",
3141 ]
3242 ` ) ;
3343 } ) ;
@@ -50,6 +60,7 @@ describe('test list command', () => {
5060
5161 expect ( logs ) . toMatchInlineSnapshot ( `
5262 [
63+ "a.test.ts > test a",
5364 "a.test.ts > test a > test a-1",
5465 "a.test.ts > test a-2",
5566 ]
@@ -73,8 +84,14 @@ describe('test list command', () => {
7384
7485 expect ( logs ) . toMatchInlineSnapshot ( `
7586 [
87+ "a.test.ts > test a",
7688 "a.test.ts > test a > test a-1",
7789 "a.test.ts > test a-2",
90+ "c.test.ts > test c describe each 0",
91+ "c.test.ts > test c describe for 0",
92+ "c.test.ts > test c describe runIf",
93+ "c.test.ts > test c describe skipIf",
94+ "c.test.ts > test c it each 0",
7895 ]
7996 ` ) ;
8097 } ) ;
@@ -99,6 +116,44 @@ describe('test list command', () => {
99116 [
100117 "a.test.ts",
101118 "b.test.ts",
119+ "c.test.ts",
120+ ]
121+ ` ) ;
122+ } ) ;
123+
124+ it ( 'should list tests correctly with printLocation' , async ( ) => {
125+ const { cli, expectExecSuccess } = await runRstestCli ( {
126+ command : 'rstest' ,
127+ args : [ 'list' , '--printLocation' ] ,
128+ options : {
129+ nodeOptions : {
130+ cwd : join ( __dirname , 'fixtures' ) ,
131+ } ,
132+ } ,
133+ } ) ;
134+
135+ await expectExecSuccess ( ) ;
136+
137+ const logs = cli . stdout ?. split ( '\n' ) . filter ( Boolean ) ;
138+
139+ // rspack transpiles describe() to (0,rstest.describe)(), so the location is end of the callee
140+ // FIXME rspack trasnpiles describe.for to describe["for"] so the location is different from describe.each
141+ expect ( logs ) . toMatchInlineSnapshot ( `
142+ [
143+ "a.test.ts:3:9 > test a",
144+ "a.test.ts:4:5 > test a > test a-1",
145+ "a.test.ts:9:3 > test a-2",
146+ "b.test.ts:3:9 > test b",
147+ "b.test.ts:4:5 > test b > test b-1",
148+ "b.test.ts:9:3 > test b-2",
149+ "c.test.ts:3:1 > test c describe each 0",
150+ "c.test.ts:5:13 > test c describe for 0",
151+ "c.test.ts:7:1 > test c describe runIf",
152+ "c.test.ts:9:1 > test c describe skipIf",
153+ "c.test.ts:11:1 > test c it each 0",
154+ "c.test.ts:13:7 > test c it for 0",
155+ "c.test.ts:15:1 > test c it runIf",
156+ "c.test.ts:17:1 > test c it skipIf",
102157 ]
103158 ` ) ;
104159 } ) ;
0 commit comments