Skip to content

Commit

Permalink
Setup test CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-sherman committed Jul 26, 2024
1 parent dd2fe75 commit 249ee35
Show file tree
Hide file tree
Showing 6 changed files with 5,390 additions and 7,252 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: PR
on: pull_request

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- run: pnpm i
- run: pnpm exec turbo run test
17 changes: 17 additions & 0 deletions packages/frontpage/lib/components/time-ago.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { afterEach, beforeEach, expect, test, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import { TimeAgo } from "./time-ago";

beforeEach(() => {
vi.useFakeTimers();
});

afterEach(() => {
vi.useRealTimers();
});

test("correct relative time", () => {
vi.setSystemTime(new Date("2024-01-02"));
render(<TimeAgo createdAt={new Date("2024-01-01")} />);
expect(screen.getByText("1 day ago")).toBeDefined();
});
10 changes: 8 additions & 2 deletions packages/frontpage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "next start",
"lint": "eslint .",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate"
"db:migrate": "drizzle-kit migrate",
"test": "vitest"
},
"dependencies": {
"@next/env": "^14.2.4",
Expand Down Expand Up @@ -45,15 +46,20 @@
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@testing-library/react": "^16.0.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@vitejs/plugin-react": "^4.3.1",
"babel-plugin-react-compiler": "0.0.0-experimental-938cd9a-20240601",
"drizzle-kit": "^0.22.7",
"eslint": "^8",
"eslint-config-next": "15.0.0-rc.0",
"jsdom": "^24.1.1",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
"typescript": "^5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.0.4"
}
}
10 changes: 10 additions & 0 deletions packages/frontpage/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
plugins: [react(), tsconfigPaths()],
test: {
environment: "jsdom",
},
});
Loading

0 comments on commit 249ee35

Please sign in to comment.