1- const configFactoryMock = vi . hoisted ( ( ) => ( {
1+ import * as configFactory from './vitest-config-factory.js' ;
2+ import {
3+ createE2ETestConfig ,
4+ createIntTestConfig ,
5+ createUnitTestConfig ,
6+ } from './vitest-setup-presets.js' ;
7+
8+ vi . mock ( './vitest-config-factory.js' , ( ) => ( {
29 createVitestConfig : vi . fn ( ) . mockReturnValue ( 'mocked-config' ) ,
310} ) ) ;
411
5- vi . mock ( './vitest-config-factory.js' , ( ) => configFactoryMock ) ;
6-
712const MOCK_PROJECT_KEY = 'test-package' ;
813
914describe ( 'vitest-setup-presets' , ( ) => {
10- let createUnitTestConfig : typeof import ( './vitest-setup-presets.js' ) . createUnitTestConfig ;
11- let createIntTestConfig : typeof import ( './vitest-setup-presets.js' ) . createIntTestConfig ;
12- let createE2ETestConfig : typeof import ( './vitest-setup-presets.js' ) . createE2ETestConfig ;
13-
14- beforeEach ( async ( ) => {
15+ beforeEach ( ( ) => {
1516 vi . clearAllMocks ( ) ;
16- ( { createUnitTestConfig, createIntTestConfig, createE2ETestConfig } =
17- await import ( './vitest-setup-presets.js' ) ) ;
1817 } ) ;
1918
2019 describe ( 'createUnitTestConfig' , ( ) => {
2120 it ( 'should call createVitestConfig with unit kind' , ( ) => {
2221 const result = createUnitTestConfig ( MOCK_PROJECT_KEY ) ;
2322
24- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenCalledWith (
23+ expect ( configFactory . createVitestConfig ) . toHaveBeenCalledWith (
2524 MOCK_PROJECT_KEY ,
2625 'unit' ,
2726 ) ;
@@ -31,7 +30,7 @@ describe('vitest-setup-presets', () => {
3130 it ( 'should handle different project names' , ( ) => {
3231 createUnitTestConfig ( 'my-custom-package' ) ;
3332
34- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenCalledWith (
33+ expect ( configFactory . createVitestConfig ) . toHaveBeenCalledWith (
3534 'my-custom-package' ,
3635 'unit' ,
3736 ) ;
@@ -40,18 +39,15 @@ describe('vitest-setup-presets', () => {
4039 it ( 'should handle empty projectKey' , ( ) => {
4140 createUnitTestConfig ( '' ) ;
4241
43- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenCalledWith (
44- '' ,
45- 'unit' ,
46- ) ;
42+ expect ( configFactory . createVitestConfig ) . toHaveBeenCalledWith ( '' , 'unit' ) ;
4743 } ) ;
4844 } ) ;
4945
5046 describe ( 'createIntTestConfig' , ( ) => {
5147 it ( 'should call createVitestConfig with int kind' , ( ) => {
5248 const result = createIntTestConfig ( MOCK_PROJECT_KEY ) ;
5349
54- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenCalledWith (
50+ expect ( configFactory . createVitestConfig ) . toHaveBeenCalledWith (
5551 MOCK_PROJECT_KEY ,
5652 'int' ,
5753 ) ;
@@ -61,7 +57,7 @@ describe('vitest-setup-presets', () => {
6157 it ( 'should handle different project names' , ( ) => {
6258 createIntTestConfig ( 'integration-package' ) ;
6359
64- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenCalledWith (
60+ expect ( configFactory . createVitestConfig ) . toHaveBeenCalledWith (
6561 'integration-package' ,
6662 'int' ,
6763 ) ;
@@ -72,7 +68,7 @@ describe('vitest-setup-presets', () => {
7268 it ( 'should call createVitestConfig with e2e kind and no options' , ( ) => {
7369 const result = createE2ETestConfig ( MOCK_PROJECT_KEY ) ;
7470
75- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenCalledWith (
71+ expect ( configFactory . createVitestConfig ) . toHaveBeenCalledWith (
7672 MOCK_PROJECT_KEY ,
7773 'e2e' ,
7874 undefined ,
@@ -87,7 +83,7 @@ describe('vitest-setup-presets', () => {
8783
8884 createE2ETestConfig ( MOCK_PROJECT_KEY , options ) ;
8985
90- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenCalledWith (
86+ expect ( configFactory . createVitestConfig ) . toHaveBeenCalledWith (
9187 MOCK_PROJECT_KEY ,
9288 'e2e' ,
9389 options ,
@@ -97,7 +93,7 @@ describe('vitest-setup-presets', () => {
9793 it ( 'should handle testTimeout option' , ( ) => {
9894 createE2ETestConfig ( MOCK_PROJECT_KEY , { testTimeout : 30_000 } ) ;
9995
100- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenCalledWith (
96+ expect ( configFactory . createVitestConfig ) . toHaveBeenCalledWith (
10197 MOCK_PROJECT_KEY ,
10298 'e2e' ,
10399 { testTimeout : 30_000 } ,
@@ -119,17 +115,17 @@ describe('vitest-setup-presets', () => {
119115 createIntTestConfig ( 'pkg2' ) ;
120116 createE2ETestConfig ( 'pkg3' ) ;
121117
122- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenNthCalledWith (
118+ expect ( configFactory . createVitestConfig ) . toHaveBeenNthCalledWith (
123119 1 ,
124120 'pkg1' ,
125121 'unit' ,
126122 ) ;
127- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenNthCalledWith (
123+ expect ( configFactory . createVitestConfig ) . toHaveBeenNthCalledWith (
128124 2 ,
129125 'pkg2' ,
130126 'int' ,
131127 ) ;
132- expect ( configFactoryMock . createVitestConfig ) . toHaveBeenNthCalledWith (
128+ expect ( configFactory . createVitestConfig ) . toHaveBeenNthCalledWith (
133129 3 ,
134130 'pkg3' ,
135131 'e2e' ,
@@ -144,7 +140,7 @@ describe('vitest-setup-presets', () => {
144140 e2e : { test : 'e2e-config' } ,
145141 } ;
146142
147- vi . mocked ( configFactoryMock . createVitestConfig )
143+ vi . mocked ( configFactory . createVitestConfig )
148144 . mockReturnValueOnce ( mockConfigs . unit as any )
149145 . mockReturnValueOnce ( mockConfigs . int as any )
150146 . mockReturnValueOnce ( mockConfigs . e2e as any ) ;
0 commit comments