@@ -18,8 +18,8 @@ describe("Resolver Plugin Tests", () => {
18
18
expect ( result . path ) . toBe ( null ) ;
19
19
} ) ;
20
20
21
- test ( "should resolve non-core module" , ( ) => {
22
- resolve . sync = jest . fn ( ( source ) => "/path/to/resolved.js" ) ;
21
+ test ( "should resolve non-core module with ESM vite config " , ( ) => {
22
+ resolve . sync = jest . fn ( ( ) => "/path/to/resolved.js" ) ;
23
23
24
24
jest . mock ( "/path/to/vite.config.js" , ( ) => ( {
25
25
default : {
@@ -29,10 +29,34 @@ describe("Resolver Plugin Tests", () => {
29
29
"_" : "/path/to/src" ,
30
30
} ,
31
31
} ,
32
- }
32
+ } ,
33
33
} ) , { virtual : true } ) ;
34
34
35
- const result = resolver . resolve ( "_/module" , "/path/to/file.js" , { configPath : "/path/to/vite.config.js" } ) ;
35
+ // JS module
36
+ let result = resolver . resolve ( "_/module" , "/path/to/file.js" , { configPath : "/path/to/vite.config.js" } ) ;
37
+
38
+ expect ( result . found ) . toBe ( true ) ;
39
+ expect ( result . path ) . toBe ( "/path/to/resolved.js" ) ;
40
+ expect ( resolve . sync ) . toHaveBeenCalledWith ( "/path/to/src/module" , {
41
+ basedir : "/path/to" ,
42
+ extensions : [ ".js" ] ,
43
+ } ) ;
44
+ } ) ;
45
+
46
+ test ( "should resolve non-core module with CJS vite config" , ( ) => {
47
+ resolve . sync = jest . fn ( ( ) => "/path/to/resolved.js" ) ;
48
+
49
+ jest . mock ( "/path/to/vite.config.js" , ( ) => ( {
50
+ resolve : {
51
+ extensions : [ ".js" ] ,
52
+ alias : {
53
+ "_" : "/path/to/src" ,
54
+ } ,
55
+ } ,
56
+ } ) , { virtual : true } ) ;
57
+
58
+ // JS module
59
+ let result = resolver . resolve ( "_/module" , "/path/to/file.js" , { configPath : "/path/to/vite.config.js" } ) ;
36
60
37
61
expect ( result . found ) . toBe ( true ) ;
38
62
expect ( result . path ) . toBe ( "/path/to/resolved.js" ) ;
0 commit comments