@@ -14,12 +14,18 @@ describe('Module Import Compatibility Tests', function() {
1414 const esmDistPath = path . join ( projectRoot , 'dist' , 'esm' ) ;
1515
1616 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+
1723 // Ensure dist directories exist
1824 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.` ) ;
2026 }
2127 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.` ) ;
2329 }
2430 } ) ;
2531
@@ -86,7 +92,12 @@ describe('Module Import Compatibility Tests', function() {
8692 const esmIndexPath = path . join ( esmDistPath , 'index.js' ) ;
8793
8894 // 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 ) ;
90101 expect ( typeof esmModule ) . to . equal ( 'object' ) ;
91102 expect ( esmModule ) . to . not . be . null ;
92103 } ) ;
@@ -95,7 +106,12 @@ describe('Module Import Compatibility Tests', function() {
95106 const esmReturnConsPath = path . join ( esmDistPath , 'index-return-cons.js' ) ;
96107 if ( fs . existsSync ( esmReturnConsPath ) ) {
97108 // 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 ) ;
99115 expect ( typeof esmReturnConsModule ) . to . equal ( 'object' ) ;
100116 expect ( esmReturnConsModule ) . to . not . be . null ;
101117 }
0 commit comments