@@ -14,12 +14,18 @@ describe('Module Import Compatibility Tests', function() {
14
14
const esmDistPath = path . join ( projectRoot , 'dist' , 'esm' ) ;
15
15
16
16
before ( function ( ) {
17
+ console . log ( 'Node.js version:' , process . version ) ;
18
+ console . log ( 'Platform:' , process . platform ) ;
19
+ console . log ( 'Project root:' , projectRoot ) ;
20
+ console . log ( 'CJS dist path:' , cjsDistPath ) ;
21
+ console . log ( 'ESM dist path:' , esmDistPath ) ;
22
+
17
23
// Ensure dist directories exist
18
24
if ( ! fs . existsSync ( cjsDistPath ) ) {
19
- throw new Error ( ' CommonJS dist directory not found. Run npm run build first.' ) ;
25
+ throw new Error ( ` CommonJS dist directory not found at ${ cjsDistPath } . Run npm run build first.` ) ;
20
26
}
21
27
if ( ! fs . existsSync ( esmDistPath ) ) {
22
- throw new Error ( ' ESM dist directory not found. Run npm run build first.' ) ;
28
+ throw new Error ( ` ESM dist directory not found at ${ esmDistPath } . Run npm run build first.` ) ;
23
29
}
24
30
} ) ;
25
31
@@ -86,7 +92,12 @@ describe('Module Import Compatibility Tests', function() {
86
92
const esmIndexPath = path . join ( esmDistPath , 'index.js' ) ;
87
93
88
94
// Use dynamic import to test ESM compatibility
89
- const esmModule = await import ( 'file://' + esmIndexPath . replace ( / \\ / g, '/' ) ) ;
95
+ // Convert Windows paths to file URLs properly
96
+ const fileUrl = process . platform === 'win32'
97
+ ? 'file:///' + esmIndexPath . replace ( / \\ / g, '/' )
98
+ : 'file://' + esmIndexPath ;
99
+
100
+ const esmModule = await import ( fileUrl ) ;
90
101
expect ( typeof esmModule ) . to . equal ( 'object' ) ;
91
102
expect ( esmModule ) . to . not . be . null ;
92
103
} ) ;
@@ -95,7 +106,12 @@ describe('Module Import Compatibility Tests', function() {
95
106
const esmReturnConsPath = path . join ( esmDistPath , 'index-return-cons.js' ) ;
96
107
if ( fs . existsSync ( esmReturnConsPath ) ) {
97
108
// Use dynamic import to test ESM compatibility
98
- const esmReturnConsModule = await import ( 'file://' + esmReturnConsPath . replace ( / \\ / g, '/' ) ) ;
109
+ // Convert Windows paths to file URLs properly
110
+ const fileUrl = process . platform === 'win32'
111
+ ? 'file:///' + esmReturnConsPath . replace ( / \\ / g, '/' )
112
+ : 'file://' + esmReturnConsPath ;
113
+
114
+ const esmReturnConsModule = await import ( fileUrl ) ;
99
115
expect ( typeof esmReturnConsModule ) . to . equal ( 'object' ) ;
100
116
expect ( esmReturnConsModule ) . to . not . be . null ;
101
117
}
0 commit comments