Skip to content

Commit

Permalink
feat: Add build test and snapshot
Browse files Browse the repository at this point in the history
This commit introduces a new build test for the project. It also
includes a snapshot for the expected output of the build process. The
build.ts file has been deleted as part of this change. A new fixture
file main.ts has been added to support the new test.
  • Loading branch information
ryoppippi committed Aug 3, 2024
1 parent 8eda436 commit 121a51a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
10 changes: 0 additions & 10 deletions build.ts

This file was deleted.

7 changes: 7 additions & 0 deletions tests/__snapshots__/build.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP

exports[`build 1`] = `
"export type Str = string;
export declare function hello(s: Str): Str;
"
`;
20 changes: 20 additions & 0 deletions tests/build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import path from 'node:path';
import { expect, test } from 'bun:test';
import dts from '../index.ts';

test('build', async () => {
const input = path.resolve(__dirname, 'fixtures/main.ts');
const dist = path.resolve(__dirname, 'out');

await Bun.build({
entrypoints: [input],
outdir: dist,
minify: false,
plugins: [dts()],
target: 'bun',
external: ['*'],
});

const outputDts = await Bun.file(path.resolve(dist, 'main.d.ts')).text();
expect(outputDts).toMatchSnapshot();
});
5 changes: 5 additions & 0 deletions tests/fixtures/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type Str = string;

export function hello(s: Str): Str {
return `hello${s}`;
}

0 comments on commit 121a51a

Please sign in to comment.