11import { createRequire } from "module" ;
22import path from "path" ;
3- import { fileURLToPath } from "url" ;
43import { describe , it , expect } from "vitest" ;
54
6- const __filename = fileURLToPath ( import . meta. url ) ;
7- const __dirname = path . dirname ( __filename ) ;
5+ // Current directory where the test file is located
6+ const currentDir = import . meta. dirname ;
7+
8+ // Get project root (go up from tests/integration to project root)
9+ const projectRoot = path . resolve ( currentDir , "../.." ) ;
810
911describe ( "Build Test" , ( ) => {
1012 it ( "should successfully require CommonJS module" , ( ) => {
1113 const require = createRequire ( __filename ) ;
12- const cjsPath = path . resolve ( __dirname , "../../ dist/cjs/lib.js" ) ;
14+ const cjsPath = path . resolve ( projectRoot , "dist/cjs/lib.js" ) ;
1315
1416 const cjsModule = require ( cjsPath ) as Record < string , unknown > ;
1517
@@ -18,7 +20,7 @@ describe("Build Test", () => {
1820 } ) ;
1921
2022 it ( "should successfully import ESM module" , async ( ) => {
21- const esmModule = ( await import ( "../../dist/lib.js" ) ) as Record < string , unknown > ;
23+ const esmModule = ( await import ( "../../dist/esm/ lib.js" ) ) as Record < string , unknown > ;
2224
2325 expect ( esmModule ) . toBeDefined ( ) ;
2426 expect ( typeof esmModule ) . toBe ( "object" ) ;
@@ -31,7 +33,7 @@ describe("Build Test", () => {
3133 const cjsModule = require ( cjsPath ) as Record < string , unknown > ;
3234
3335 // Import ESM module
34- const esmModule = ( await import ( "../../dist/lib.js" ) ) as Record < string , unknown > ;
36+ const esmModule = ( await import ( "../../dist/esm/ lib.js" ) ) as Record < string , unknown > ;
3537
3638 // Compare exports
3739 const cjsKeys = Object . keys ( cjsModule ) . sort ( ) ;
0 commit comments