From 1cf4c52ed6477d609d08b253e06f664e5ce1b2ab Mon Sep 17 00:00:00 2001 From: Dale Seo Date: Tue, 22 Oct 2024 20:17:38 -0400 Subject: [PATCH 1/3] fix: type erros with jest-dom --- .gitignore | 5 ++++- tsconfig.app.json | 2 +- vite.config.ts | 2 +- src/vitest.setup.ts => vitest.setup.ts | 0 4 files changed, 6 insertions(+), 3 deletions(-) rename src/vitest.setup.ts => vitest.setup.ts (100%) diff --git a/.gitignore b/.gitignore index a0ee7b1..9def78f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,7 @@ dist-ssr styled-system # Tests -coverage \ No newline at end of file +coverage + +# TypeScript +*.tsbuildinfo diff --git a/tsconfig.app.json b/tsconfig.app.json index 89bc350..6324a38 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -23,7 +23,7 @@ "include": [ "src", /* Vitest */ - "src/vitest.setup.ts", + "vitest.setup.ts", /* PandaCSS */ "styled-system" ] diff --git a/vite.config.ts b/vite.config.ts index 2dff920..3e99757 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -8,7 +8,7 @@ export default defineConfig({ plugins: [react()], test: { environment: "happy-dom", - setupFiles: ["./src/vitest.setup.ts"], + setupFiles: ["./vitest.setup.ts"], coverage: { include: ["src/**/*.ts?(x)"], thresholds: { diff --git a/src/vitest.setup.ts b/vitest.setup.ts similarity index 100% rename from src/vitest.setup.ts rename to vitest.setup.ts From 56e239fe0fbd965f72223d71a7680e22434c3e2c Mon Sep 17 00:00:00 2001 From: Dale Seo Date: Tue, 22 Oct 2024 20:19:14 -0400 Subject: [PATCH 2/3] ci: add integration workflow --- .github/workflows/integration.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/integration.yml diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..f3f00d8 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,16 @@ +name: 🔄 Integration + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + - run: bun install + - run: bun run format:check + - run: bun run lint + - run: bun run coverage + - run: bun run build From 3f79d97e9a7a201e39fc30da44bb759061339475 Mon Sep 17 00:00:00 2001 From: Dale Seo Date: Tue, 22 Oct 2024 20:32:41 -0400 Subject: [PATCH 3/3] chore: do not clutter test output with errors --- src/components/ErrorPage/ErrorPage.test.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/ErrorPage/ErrorPage.test.tsx b/src/components/ErrorPage/ErrorPage.test.tsx index c2f64b6..f663128 100644 --- a/src/components/ErrorPage/ErrorPage.test.tsx +++ b/src/components/ErrorPage/ErrorPage.test.tsx @@ -1,11 +1,19 @@ import { faker } from "@faker-js/faker"; import { render, screen } from "@testing-library/react"; import { useRouteError } from "react-router-dom"; -import { expect, test, vi } from "vitest"; +import { afterAll, beforeAll, expect, test, vi } from "vitest"; import ErrorPage from "./ErrorPage"; vi.mock("react-router-dom"); +beforeAll(() => { + vi.spyOn(console, "error").mockImplementation(() => {}); +}); + +afterAll(() => { + vi.mocked(console.error).mockRestore(); +}); + test("displays the title and message", () => { vi.mocked(useRouteError).mockReturnValue({ statusText: faker.lorem.sentence(),