Skip to content

Commit

Permalink
Add test against the bundled assets (#257)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiachi Liu <[email protected]>
  • Loading branch information
devjiwonchoi and huozhi authored Sep 23, 2023
1 parent 559d951 commit 43213b2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion test/compile.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import fs, { promises as fsp } from 'fs'
import { resolve, dirname, extname } from 'path'
import { bundle } from 'bunchee'
import { existsFile, fullExtension } from './testing-utils'

const assetPath = process.env.POST_BUILD ? '../dist' : '../src/bundle'
const bundle = require(assetPath).default

jest.setTimeout(10 * 60 * 1000)

const baseUnitTestDir = resolve(__dirname, 'unit')
Expand Down
6 changes: 5 additions & 1 deletion test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,14 @@ async function runBundle(
dir: string,
args_: string[],
): Promise<{ code: number | null; stdout: string; stderr: string }> {
const assetPath = process.env.POST_BUILD
? '/../dist/cli.js'
: '/../src/cli.ts'

const args = (args_ || []).concat(['--cwd', dir])
const ps = fork(
`${require.resolve('tsx/cli')}`,
[__dirname + '/../src/cli.ts'].concat(args),
[__dirname + assetPath].concat(args),
{ stdio: 'pipe' },
)
let stderr = '',
Expand Down
2 changes: 2 additions & 0 deletions test/post-build/compile.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../compile.test'
process.env.POST_BUILD = '1'
2 changes: 2 additions & 0 deletions test/post-build/integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../integration.test'
process.env.POST_BUILD = '1'

0 comments on commit 43213b2

Please sign in to comment.