66import type { Entry } from '#src/interfaces'
77import loaders from '#src/utils/loaders'
88import type { Mock } from '#tests/interfaces'
9+ import getPackageJson from '#tests/utils/get-package-json'
910import * as mlly from '@flex-development/mlly'
1011import * as pathe from '@flex-development/pathe'
12+ import type { PackageJson } from '@flex-development/pkg-types'
1113import * as esbuild from 'esbuild'
1214import testSubject from '../esbuilder'
1315
14- vi . mock ( '#src/plugins/write/plugin ' )
16+ vi . mock ( '#src/utils/fs ' )
1517vi . mock ( 'esbuild' )
1618
1719describe ( 'integration:internal/esbuilder' , ( ) => {
@@ -34,20 +36,22 @@ describe('integration:internal/esbuilder', () => {
3436 let absWorkingDir : string
3537 let entry : Partial < Entry >
3638 let format : esbuild . Format
39+ let pkg : PackageJson
3740
38- beforeAll ( ( ) => {
39- entry = { cwd : '__fixtures__/pkg/find-uniq ' }
41+ beforeAll ( async ( ) => {
42+ entry = { cwd : '__fixtures__/pkg/buddy ' }
4043 absWorkingDir = pathe . resolve ( entry . cwd ! ) + pathe . sep
4144 format = entry . format = 'cjs'
45+ pkg = await getPackageJson ( pathe . join ( absWorkingDir , 'package.json' ) )
4246 } )
4347
4448 it ( 'should create bundle in cjs format' , async ( ) => {
4549 // Arrange
4650 const bundle : boolean = true
47- const source : string = 'find-uniq.cts '
51+ const source : string = 'buddy.js '
4852
4953 // Act
50- const [ , results ] = await testSubject ( { ...entry , bundle, source } )
54+ const [ , results ] = await testSubject ( { ...entry , bundle, source } , pkg )
5155
5256 // Expect
5357 expect ( results ) . toMatchSnapshot ( )
@@ -74,11 +78,14 @@ describe('integration:internal/esbuilder', () => {
7478
7579 it ( 'should do transpilation in cjs format' , async ( ) => {
7680 // Arrange
77- const pattern : string = 'find-uniq.cts '
81+ const pattern : string = 'buddy.js '
7882 const source : string = '.'
7983
8084 // Act
81- const [ , results ] = await testSubject ( { ...entry , pattern, source } )
85+ const [ , results ] = await testSubject (
86+ { ...entry , pattern, source } ,
87+ pkg
88+ )
8289
8390 // Expect
8491 expect ( results ) . toMatchSnapshot ( )
@@ -214,15 +221,15 @@ describe('integration:internal/esbuilder', () => {
214221 let format : esbuild . Format
215222
216223 beforeAll ( ( ) => {
217- entry = { cwd : '__fixtures__/pkg/buddy ' }
224+ entry = { cwd : '__fixtures__/pkg/find-uniq ' }
218225 absWorkingDir = pathe . resolve ( entry . cwd ! ) + pathe . sep
219226 format = entry . format = 'iife'
220227 } )
221228
222229 it ( 'should create bundle in iife format' , async ( ) => {
223230 // Arrange
224231 const bundle : boolean = true
225- const source : string = 'buddy.js '
232+ const source : string = 'find-uniq.cts '
226233
227234 // Act
228235 const [ , results ] = await testSubject ( { ...entry , bundle, source } )
@@ -252,7 +259,7 @@ describe('integration:internal/esbuilder', () => {
252259
253260 it ( 'should do transpilation in iife format' , async ( ) => {
254261 // Arrange
255- const pattern : string = 'buddy.js '
262+ const pattern : string = 'find-uniq.cts '
256263 const source : string = '.'
257264
258265 // Act
0 commit comments