Skip to content

Commit

Permalink
test: add ts composite test case (#414)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiachi Liu <[email protected]>
  • Loading branch information
himself65 and huozhi authored Jan 16, 2024
1 parent a31f9d7 commit 3b0eb85
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const getPath = (filepath: string) => join(integrationTestDir, filepath)
const testCases: {
name: string
dir?: string
skip?: boolean
args?: string[]
before?(dir: string): Promise<void> | void
expected(
Expand Down Expand Up @@ -842,6 +843,16 @@ const testCases: {
expect(stderr).toContain('./dist/foo.cjs')
},
},
{
name: 'ts-composite',
dir: 'monorepo/packages/package',
skip: true,
args: [],
async expected(dir) {
expect(await existsFile(join(dir, './dist/index.js'))).toBe(true)
expect(await existsFile(join(dir, './dist/index.d.ts'))).toBe(true)
},
},
]

async function runBundle(
Expand Down Expand Up @@ -875,8 +886,11 @@ async function runBundle(

function runTests() {
for (const testCase of testCases) {
const { name, args = [], expected, before } = testCase
const { name, args = [], expected, before, skip } = testCase
const dir = getPath(testCase.dir ?? name)
if (skip) {
return
}
test(`integration ${name}`, async () => {
debug.log(`Command: bunchee ${args.join(' ')}`)
if (before) {
Expand Down
6 changes: 6 additions & 0 deletions test/integration/monorepo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "monorepo",
"dependencies": {
"package": "link:./packages/package"
}
}
5 changes: 5 additions & 0 deletions test/integration/monorepo/packages/package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "package",
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
}
3 changes: 3 additions & 0 deletions test/integration/monorepo/packages/package/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function foo () {
return 'bar'
}
7 changes: 7 additions & 0 deletions test/integration/monorepo/packages/package/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler"
}
}
11 changes: 11 additions & 0 deletions test/integration/monorepo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"composite": true,
"incremental": true
},
"references": [
{
"path": "./packages/package"
}
]
}

0 comments on commit 3b0eb85

Please sign in to comment.