@@ -5,9 +5,9 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
55
66// Import parse function from parsers
77
8- import { parseCucumberFeature } from '../../src/parsers/cucumber.js'
98import { parse } from '../../src/parsers/index.js'
109import { parseTestCases } from '../../src/parsers/js.js'
10+ import { getCucumberParser } from '../../src/parsers/utils.js'
1111import type { ReadSpecsOptions } from '@vscode-wdio/types/api'
1212import type { WorkerMetaContext , TestData , CucumberTestData } from '@vscode-wdio/types/worker'
1313
@@ -18,8 +18,8 @@ vi.mock('node:fs/promises', () => ({
1818} ) )
1919
2020// Mock the parsers
21- vi . mock ( '../../src/parsers/cucumber .js' , ( ) => ( {
22- parseCucumberFeature : vi . fn ( ) ,
21+ vi . mock ( '../../src/parsers/utils .js' , ( ) => ( {
22+ getCucumberParser : vi . fn ( ) ,
2323} ) )
2424
2525vi . mock ( '../../src/parsers/js.js' , ( ) => ( {
@@ -87,13 +87,14 @@ describe('Parser Index', () => {
8787 metadata : { } ,
8888 } ,
8989 ]
90+ const mockCucumberParser = vi . fn ( ( ) => cucumberMockTestData )
9091
9192 beforeEach ( ( ) => {
9293 vi . resetAllMocks ( )
9394
9495 // Mock the parseTestCases and parseCucumberFeature functions
9596 vi . mocked ( parseTestCases ) . mockReturnValue ( jsMockTestData )
96- vi . mocked ( parseCucumberFeature ) . mockReturnValue ( cucumberMockTestData )
97+ vi . mocked ( getCucumberParser ) . mockResolvedValue ( mockCucumberParser )
9798 } )
9899
99100 afterEach ( ( ) => {
@@ -120,7 +121,7 @@ describe('Parser Index', () => {
120121
121122 // Verify the correct parser was called
122123 expect ( parseTestCases ) . toHaveBeenCalledWith ( jsTestContent , path . normalize ( '/path/to/test.js' ) )
123- expect ( parseCucumberFeature ) . not . toHaveBeenCalled ( )
124+ expect ( mockCucumberParser ) . not . toHaveBeenCalled ( )
124125
125126 // Verify logging
126127 expect ( mockContext . log . debug ) . toHaveBeenCalledWith ( `Parse spec file: ${ path . normalize ( '/path/to/test.js' ) } ` )
@@ -148,7 +149,7 @@ describe('Parser Index', () => {
148149
149150 // Verify the correct parser was called
150151 expect ( parseTestCases ) . toHaveBeenCalledWith ( jsTestContent , path . normalize ( '/path/to/test.ts' ) )
151- expect ( parseCucumberFeature ) . not . toHaveBeenCalled ( )
152+ expect ( mockCucumberParser ) . not . toHaveBeenCalled ( )
152153 } )
153154
154155 it ( 'should parse Cucumber feature files correctly' , async ( ) => {
@@ -169,7 +170,7 @@ describe('Parser Index', () => {
169170 expect ( result [ 0 ] . tests ) . toEqual ( cucumberMockTestData )
170171
171172 // Verify the correct parser was called
172- expect ( parseCucumberFeature ) . toHaveBeenCalledWith (
173+ expect ( mockCucumberParser ) . toHaveBeenCalledWith (
173174 cucumberFeatureContent ,
174175 path . normalize ( '/path/to/test.feature' )
175176 )
@@ -194,7 +195,7 @@ describe('Parser Index', () => {
194195 expect ( result [ 0 ] . tests ) . toEqual ( cucumberMockTestData )
195196
196197 // Verify the correct parser was called
197- expect ( parseCucumberFeature ) . toHaveBeenCalledWith (
198+ expect ( mockCucumberParser ) . toHaveBeenCalledWith (
198199 cucumberFeatureContent ,
199200 path . normalize ( '/path/to/test.FEATURE' )
200201 )
@@ -232,7 +233,7 @@ describe('Parser Index', () => {
232233
233234 // Verify the correct parsers were called
234235 expect ( parseTestCases ) . toHaveBeenCalledWith ( jsTestContent , path . normalize ( '/path/to/test.js' ) )
235- expect ( parseCucumberFeature ) . toHaveBeenCalledWith (
236+ expect ( mockCucumberParser ) . toHaveBeenCalledWith (
236237 cucumberFeatureContent ,
237238 path . normalize ( '/path/to/test.feature' )
238239 )
@@ -284,7 +285,7 @@ describe('Parser Index', () => {
284285 expect ( result ) . toEqual ( [ ] )
285286 expect ( fs . readFile ) . not . toHaveBeenCalled ( )
286287 expect ( parseTestCases ) . not . toHaveBeenCalled ( )
287- expect ( parseCucumberFeature ) . not . toHaveBeenCalled ( )
288+ expect ( mockCucumberParser ) . not . toHaveBeenCalled ( )
288289 } )
289290 } )
290291} )
0 commit comments