@@ -5,8 +5,8 @@ import { join } from 'node:path'
55import { describe , it , expect , vi , beforeEach , afterEach } from 'vitest'
66
77import { getLauncherInstance } from '../src/cli.js'
8- import { createTempConfigFile , isWindows } from '../src/config.js'
98import { runTest } from '../src/test.js'
9+ import { getTempConfigCreator , isWindows } from '../src/utils.js'
1010import type { Dirent } from 'node:fs'
1111import type { WorkerMetaContext } from '@vscode-wdio/types/worker'
1212
@@ -21,10 +21,11 @@ vi.mock('../src/cli.js', () => {
2121 )
2222 return { getLauncherInstance }
2323} )
24- vi . mock ( '../src/config.js' , ( ) => {
24+
25+ vi . mock ( '../src/utils.js' , ( ) => {
2526 return {
26- createTempConfigFile : vi . fn ( async ( config ) => config ) ,
2727 isWindows : vi . fn ( ( ) => false ) ,
28+ getTempConfigCreator : vi . fn ( ) ,
2829 }
2930} )
3031
@@ -52,6 +53,7 @@ describe('runTest', () => {
5253 const mockResultDir = '/mock/tmp/dir/result-xyz123'
5354 const mockResultFile = 'wdio-0-0.json'
5455 const mockResultData = JSON . stringify ( { some : 'test result' } )
56+ const mockTempConfigCreator = vi . fn ( async ( ) => '/path/to/customized/wdio.conf.ts' )
5557
5658 beforeEach ( ( ) => {
5759 // Reset mocks
@@ -63,10 +65,13 @@ describe('runTest', () => {
6365 vi . mocked ( fs . mkdir ) . mockResolvedValue ( undefined )
6466 vi . mocked ( fs . mkdtemp ) . mockResolvedValue ( mockResultDir )
6567 vi . mocked ( fs . access ) . mockResolvedValue ( undefined )
68+ // @ts -ignore
6669 vi . mocked ( fs . readdir ) . mockResolvedValue ( [ mockResultFile as unknown as Dirent ] )
6770 vi . mocked ( fs . readFile ) . mockResolvedValue ( Buffer . from ( mockResultData ) )
6871 vi . mocked ( fs . rm ) . mockResolvedValue ( undefined )
6972
73+ vi . mocked ( getTempConfigCreator ) . mockResolvedValue ( mockTempConfigCreator )
74+
7075 // Mock console methods
7176 vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } )
7277 vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } )
@@ -104,7 +109,6 @@ describe('runTest', () => {
104109
105110 it ( 'should run tests successfully and return results on the windows' , async ( ) => {
106111 vi . mocked ( isWindows ) . mockReturnValue ( true )
107- vi . mocked ( createTempConfigFile ) . mockResolvedValue ( '/path/to/customized/wdio.conf.ts' )
108112 // Act
109113 const result = await runTest . call ( mockContext , mockOptions )
110114
@@ -122,7 +126,7 @@ describe('runTest', () => {
122126 expect ( fs . mkdtemp ) . toHaveBeenCalledWith ( join ( mockTmpDir , 'vscode-webdriverio' , 'result-' ) )
123127
124128 // Verify createTempConfigFile were called
125- expect ( createTempConfigFile ) . toHaveBeenCalledWith ( mockConfigFile , mockResultDir )
129+ expect ( mockTempConfigCreator ) . toHaveBeenCalledWith ( mockConfigFile , mockResultDir )
126130
127131 // Verify result files were read
128132 expect ( fs . readdir ) . toHaveBeenCalledWith ( mockResultDir )
0 commit comments