@@ -3,30 +3,32 @@ import { CONFIG_FILE_NAME, type CoreConfig } from '@code-pushup/models';
33import { MEMFS_VOLUME } from '@code-pushup/test-utils' ;
44import { autoloadRc } from './read-rc-file.js' ;
55
6- // mock importModule from @code -pushup/utils to bypass jiti which doesn't work with memfs
7- vi . mock ( '@code-pushup/utils' , async ( ) => {
8- const utils : object = await vi . importActual ( '@code-pushup/utils' ) ;
6+ // mock bundleRequire inside importEsmModule used for fetching config
7+ vi . mock ( 'bundle-require' , async ( ) => {
98 const { CORE_CONFIG_MOCK } : Record < string , CoreConfig > =
109 await vi . importActual ( '@code-pushup/test-fixtures' ) ;
1110
12- const mockImportModule = async ( options : { filepath : string } ) => {
13- const extension = options . filepath . split ( '.' ) . at ( - 1 ) ;
14- return {
15- ...CORE_CONFIG_MOCK ,
16- upload : {
17- ...CORE_CONFIG_MOCK ?. upload ,
18- project : extension , // returns loaded file extension to check format precedence
19- } ,
20- } ;
21- } ;
22-
2311 return {
24- ...utils ,
25- importModule : mockImportModule ,
12+ bundleRequire : vi
13+ . fn ( )
14+ . mockImplementation ( ( options : { filepath : string } ) => {
15+ const extension = options . filepath . split ( '.' ) . at ( - 1 ) ;
16+ return {
17+ mod : {
18+ default : {
19+ ...CORE_CONFIG_MOCK ,
20+ upload : {
21+ ...CORE_CONFIG_MOCK ?. upload ,
22+ project : extension , // returns loaded file extension to check format precedence
23+ } ,
24+ } ,
25+ } ,
26+ } ;
27+ } ) ,
2628 } ;
2729} ) ;
2830
29- // Note: memfs files are only listed to satisfy a system check, value is used from the mocked importModule
31+ // Note: memfs files are only listed to satisfy a system check, value is used from bundle-require mock
3032describe ( 'autoloadRc' , ( ) => {
3133 it ( 'prioritise a .ts configuration file' , async ( ) => {
3234 vol . fromJSON (
0 commit comments