11import type { CliOptions , TestCase , TestModule , TestSuite } from 'vitest/node'
22import { expect , test } from 'vitest'
3- import { createVitest } from 'vitest/node'
3+ import { createVitest , rolldownVersion } from 'vitest/node'
44
55test ( 'correctly collects a simple test' , async ( ) => {
66 const testModule = await collectTests ( `
@@ -575,6 +575,7 @@ test('collects tests with each modifier', async () => {
575575 "each tests": {
576576 "barTest with each %i": {
577577 "dynamic": true,
578+ "each": true,
578579 "errors": [],
579580 "fullName": "each tests > barTest with each %i",
580581 "id": "-1732721377_0_2-dynamic",
@@ -584,6 +585,7 @@ test('collects tests with each modifier', async () => {
584585 },
585586 "test with each %i": {
586587 "dynamic": true,
588+ "each": true,
587589 "errors": [],
588590 "fullName": "each tests > test with each %i",
589591 "id": "-1732721377_0_0-dynamic",
@@ -593,6 +595,7 @@ test('collects tests with each modifier', async () => {
593595 },
594596 "testFoo with each %i": {
595597 "dynamic": true,
598+ "each": true,
596599 "errors": [],
597600 "fullName": "each tests > testFoo with each %i",
598601 "id": "-1732721377_0_1-dynamic",
@@ -812,15 +815,22 @@ function testTree(module: TestModule | TestSuite, tree: any = {}) {
812815}
813816
814817function testItem ( testCase : TestCase ) {
818+ let location : string | undefined
819+ if ( testCase . location ) {
820+ // rolldown's column is moved by 1 when using test.each/test.for
821+ const column = rolldownVersion && testCase . options . each
822+ ? testCase . location . column - 1
823+ : testCase . location . column
824+ location = `${ testCase . location . line } :${ column } `
825+ }
815826 return {
816827 id : testCase . id ,
817- location : testCase . location
818- ? `${ testCase . location . line } :${ testCase . location . column } `
819- : undefined ,
828+ location,
820829 mode : testCase . options . mode ,
821830 fullName : testCase . fullName ,
822831 state : testCase . result ( ) . state ,
823832 errors : testCase . result ( ) . errors || [ ] ,
824833 ...( testCase . task . dynamic ? { dynamic : true } : { } ) ,
834+ ...( testCase . options . each ? { each : true } : { } ) ,
825835 }
826836}
0 commit comments