@@ -8,10 +8,12 @@ const currentDir = import.meta.dirname;
8
8
// Get project root (go up from tests/integration to project root)
9
9
const projectRoot = path . resolve ( currentDir , "../.." ) ;
10
10
11
+ const esmPath = path . resolve ( projectRoot , "dist/esm/lib.js" ) ;
12
+ const cjsPath = path . resolve ( projectRoot , "dist/cjs/lib.js" ) ;
13
+
11
14
describe ( "Build Test" , ( ) => {
12
15
it ( "should successfully require CommonJS module" , ( ) => {
13
16
const require = createRequire ( __filename ) ;
14
- const cjsPath = path . resolve ( projectRoot , "dist/cjs/lib.js" ) ;
15
17
16
18
const cjsModule = require ( cjsPath ) as Record < string , unknown > ;
17
19
@@ -20,7 +22,7 @@ describe("Build Test", () => {
20
22
} ) ;
21
23
22
24
it ( "should successfully import ESM module" , async ( ) => {
23
- const esmModule = ( await import ( "../../dist/esm/lib.js" ) ) as Record < string , unknown > ;
25
+ const esmModule = ( await import ( esmPath ) ) as Record < string , unknown > ;
24
26
25
27
expect ( esmModule ) . toBeDefined ( ) ;
26
28
expect ( typeof esmModule ) . toBe ( "object" ) ;
@@ -29,11 +31,10 @@ describe("Build Test", () => {
29
31
it ( "should have matching exports between CommonJS and ESM modules" , async ( ) => {
30
32
// Import CommonJS module
31
33
const require = createRequire ( __filename ) ;
32
- const cjsPath = path . resolve ( __dirname , "../../dist/cjs/lib.js" ) ;
33
34
const cjsModule = require ( cjsPath ) as Record < string , unknown > ;
34
35
35
36
// Import ESM module
36
- const esmModule = ( await import ( "../../dist/esm/lib.js" ) ) as Record < string , unknown > ;
37
+ const esmModule = ( await import ( esmPath ) ) as Record < string , unknown > ;
37
38
38
39
// Compare exports
39
40
const cjsKeys = Object . keys ( cjsModule ) . sort ( ) ;
0 commit comments