Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 61f83ce

Browse files
committed
✅ Chore: add testing infrastructure with bun
1 parent 4764fe6 commit 61f83ce

File tree

9 files changed

+54
-4
lines changed

9 files changed

+54
-4
lines changed

bun.lockb

26.8 KB
Binary file not shown.

buntest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@testing-library/jest-dom'

global.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="@testing-library/jest-dom" />
2+

jest.setup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@testing-library/jest-dom';
2+

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@
1414
"db:review": "bunx prisma studio",
1515
"db:full-sync": "bun run scripts/db-full-sync.ts",
1616
"db:backup": "bun run scripts/backup-db.ts",
17-
"db:restore": "bun run scripts/restore-db.ts"
17+
"db:restore": "bun run scripts/restore-db.ts",
18+
"test": "bun test",
19+
"test:watch": "bun test --watch"
1820
},
21+
"jest": {
22+
"setupFilesAfterEnv": ["<rootDir>/jest.setup.ts"]
23+
},
24+
"trustedDependencies": ["@testing-library/react"],
1925
"prisma": {
2026
"seed": "bun prisma/seed.ts"
2127
},
@@ -101,16 +107,21 @@
101107
"zustand": "^5.0.1"
102108
},
103109
"devDependencies": {
110+
"@testing-library/jest-dom": "^6.6.3",
111+
"@testing-library/react": "^16.0.1",
104112
"@types/bcrypt": "^5.0.2",
105113
"@types/bcryptjs": "^2.4.6",
114+
"@types/jest": "^29.5.14",
106115
"@types/node": "^22.9.1",
107116
"@types/nodemailer": "^6.4.17",
108117
"@types/prismjs": "^1.26.5",
109118
"@types/react": "npm:[email protected]",
110119
"@types/react-dom": "npm:[email protected]",
111120
"autoprefixer": "^10.4.20",
121+
"bun-types": "^1.1.36",
112122
"eslint": "^9.15.0",
113123
"eslint-config-next": "15.0.3",
124+
"jest-environment-jsdom": "^29.7.0",
114125
"postcss": "^8.4.49",
115126
"prisma": "^5.22.0",
116127
"tailwindcss": "^3.4.15",

src/app/__tests__/page.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { expect, test, describe } from "bun:test";
2+
import { render, screen } from '@testing-library/react';
3+
import Page from '@/app/page';
4+
5+
declare module "bun:test" {
6+
interface Matchers<T = unknown> {
7+
toBeInTheDocument(): boolean;
8+
toHaveTextContent(text: string): boolean;
9+
toBeVisible(): boolean;
10+
}
11+
}
12+
13+
describe('Home Page', () => {
14+
test('renders heading', () => {
15+
render(<Page />);
16+
17+
const heading = screen.getByRole('heading', {
18+
name: /welcome/i,
19+
});
20+
21+
expect(heading).toBeInTheDocument();
22+
});
23+
});

test.setup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@testing-library/jest-dom';
2+

tsconfig.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@
2020
],
2121
"paths": {
2222
"@/*": ["./src/*"]
23-
}
23+
},
24+
"types": ["bun-types", "@testing-library/jest-dom", "jest"]
2425
},
25-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26-
"exclude": ["node_modules"]
26+
"include": [
27+
"next-env.d.ts",
28+
"**/*.ts",
29+
"**/*.tsx",
30+
".next/types/**/*.ts",
31+
"global.d.ts"
32+
],
33+
"exclude": ["node_modules"]
2734
}

types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="bun-types" />
2+

0 commit comments

Comments
 (0)