Skip to content

Commit c200839

Browse files
committed
cp
2 parents 8c8def3 + d7ae524 commit c200839

File tree

7 files changed

+1605
-77
lines changed

7 files changed

+1605
-77
lines changed

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Test"
2+
on:
3+
push:
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
steps:
14+
- name: Check out repository code
15+
uses: actions/checkout@v4
16+
17+
- uses: pnpm/action-setup@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: "pnpm"
22+
23+
- shell: bash
24+
run: pnpm install
25+
- name: Install @vitest/coverage-v8
26+
run: pnpm add -D @vitest/coverage-v8
27+
- name: "Test"
28+
run: npx vitest --coverage.enabled true

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,11 @@ When you're ready to deploy your SaaS application to production, follow these st
7171
### Add environment variables
7272

7373
In your Vercel project settings (or during deployment), add all the necessary environment variables. Make sure to update the values for the production environment.
74+
75+
## Running Tests
76+
77+
To run specs:
78+
79+
```bash
80+
pnpm vitest
81+
```

app/(dashboard)/page.test.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from "react";
2+
import { describe, it, expect, vi } from "vitest";
3+
import { render, screen } from "@testing-library/react";
4+
import Homepage from "./page";
5+
import { ClerkProvider, SignedOut, SignedIn } from "@clerk/nextjs";
6+
7+
vi.mock("@/components/ui/button", () => ({
8+
Button: ({ children }: { children: React.ReactNode }) => (
9+
<button>{children}</button>
10+
),
11+
}));
12+
13+
vi.mock("@clerk/nextjs", async (importOriginal) => {
14+
const actual = await importOriginal();
15+
return {
16+
...actual,
17+
ClerkProvider: ({ children }: { children: React.ReactNode }) => (
18+
<>{children}</>
19+
),
20+
SignedOut: ({ children }: { children: React.ReactNode }) => <>{children}</>,
21+
SignedIn: ({ children }: { children: React.ReactNode }) => <>{children}</>,
22+
};
23+
});
24+
25+
describe("Homepage", () => {
26+
it("renders the correct heading", () => {
27+
render(
28+
<ClerkProvider>
29+
<Homepage />
30+
</ClerkProvider>
31+
);
32+
33+
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent(
34+
"Write Your Tests"
35+
);
36+
});
37+
});

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"private": true,
3+
"type": "module",
4+
"packageManager": "pnpm@9.7.1",
35
"scripts": {
46
"dev": "next dev --turbo",
57
"build": "next build",
@@ -8,7 +10,8 @@
810
"db:seed": "npx tsx lib/db/seed.ts",
911
"db:generate": "drizzle-kit generate",
1012
"db:migrate": "npx tsx lib/db/migrate.ts",
11-
"db:studio": "drizzle-kit studio"
13+
"db:studio": "drizzle-kit studio",
14+
"test": "vitest"
1215
},
1316
"dependencies": {
1417
"@ai-sdk/openai": "^0.0.61",
@@ -57,9 +60,16 @@
5760
"tailwindcss-react-aria-components": "1.1.5",
5861
"typescript": "^5.6.2",
5962
"vaul": "^0.9.4",
63+
"vite-tsconfig-paths": "^5.0.1",
6064
"zod": "^3.23.8"
6165
},
6266
"devDependencies": {
63-
"smee-client": "^2.0.3"
67+
"@testing-library/jest-dom": "^6.5.0",
68+
"@testing-library/react": "^16.0.1",
69+
"@vitejs/plugin-react": "^4.3.1",
70+
"happy-dom": "^15.7.4",
71+
"jsdom": "^25.0.1",
72+
"smee-client": "^2.0.3",
73+
"vitest": "^2.1.1"
6474
}
6575
}

0 commit comments

Comments
 (0)