Skip to content

Commit

Permalink
test: move to vitest (#63)
Browse files Browse the repository at this point in the history
Closes #59
  • Loading branch information
pvcnt authored Aug 2, 2024
1 parent 6d97194 commit 1b38ccb
Show file tree
Hide file tree
Showing 24 changed files with 856 additions and 215 deletions.
5 changes: 0 additions & 5 deletions apps/web/jest-setup.ts

This file was deleted.

8 changes: 0 additions & 8 deletions apps/web/jest.config.ts

This file was deleted.

11 changes: 5 additions & 6 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview",
"typecheck": "tsc --noemit",
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"test": "jest"
"test": "vitest run"
},
"dependencies": {
"@blueprintjs/core": "^5.10.3",
Expand All @@ -32,28 +32,27 @@
"remeda": "^2.0.5"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@repo/eslint-config": "workspace:*",
"@repo/jest-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@tanstack/eslint-plugin-query": "^5.50.1",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^22.1.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.0",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"fake-indexeddb": "^6.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^24.1.1",
"sass": "^1.77.6",
"typescript": "^5.4.5",
"typescript-plugin-css-modules": "^5.1.0",
"vite": "^5.2.12",
"vite-plugin-comlink": "^5.0.1",
"vite-tsconfig-paths": "^4.3.2"
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.0.5"
}
}
5 changes: 1 addition & 4 deletions apps/web/src/components/CommandBar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* @jest-environment jsdom
*/
import { describe, expect, test, beforeAll, afterAll } from "@jest/globals";
import { describe, expect, test, beforeAll, afterAll } from "vitest";
import { render, screen } from "@testing-library/react";
import { userEvent, type UserEvent } from "@testing-library/user-event";
import { PullState } from "@repo/types";
Expand Down
5 changes: 1 addition & 4 deletions apps/web/src/components/ConnectionDialog.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* @jest-environment jsdom
*/
import { describe, test, expect, beforeEach } from "@jest/globals";
import { describe, test, expect, beforeEach } from "vitest";
import { render, screen } from "@testing-library/react";
import { userEvent, type UserEvent } from "@testing-library/user-event";
import ConnectionDialog from "./ConnectionDialog";
Expand Down
5 changes: 1 addition & 4 deletions apps/web/src/components/Footer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* @jest-environment jsdom
*/
import { test, expect } from "@jest/globals";
import { test, expect } from "vitest";
import { render } from "@testing-library/react";
import Footer from "./Footer";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/size.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from "@jest/globals";
import { test, expect } from "vitest";
import { Pull, PullState } from "@repo/types";
import { computeSize } from "./size";

Expand Down
6 changes: 6 additions & 0 deletions apps/web/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { afterEach } from "vitest";
import { cleanup } from "@testing-library/react";
import "@testing-library/jest-dom/vitest";

// Auto-cleanup after each test.
afterEach(() => cleanup());
3 changes: 2 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"extends": "@repo/typescript-config/vite.json",
"compilerOptions": {
"plugins": [{ "name": "typescript-plugin-css-modules" }],
"types": ["@testing-library/jest-dom"],
"paths": {
"@/*": ["./src/*"],
}
},
"include": ["src", "*.ts"],
"include": ["src", "*.ts"]
}
15 changes: 15 additions & 0 deletions apps/web/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference types="node" />
import path from "path";
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
environment: "jsdom",
setupFiles: ["fake-indexeddb/auto", "test-setup.ts"],
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
});
2 changes: 1 addition & 1 deletion packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier",
],
ignorePatterns: [".eslintrc.cjs", "jest.config.cjs"],
ignorePatterns: [".eslintrc.cjs"],
plugins: ["@typescript-eslint"],
parserOptions: {
sourceType: "module",
Expand Down
5 changes: 0 additions & 5 deletions packages/github/jest.config.ts

This file was deleted.

8 changes: 3 additions & 5 deletions packages/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
"scripts": {
"typecheck": "tsc --noemit",
"lint": "eslint \"**/*.ts\"",
"test": "jest"
"test": "vitest run"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@repo/eslint-config": "workspace:*",
"@repo/jest-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vitest": "^2.0.5"
},
"dependencies": {
"@octokit/core": "^6.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/github/src/search.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, expect } from "@jest/globals";
import { describe, test, expect } from "vitest";
import { SearchQuery, SearchOp, SearchTerm } from "./search";

describe("SearchQuery", () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/github/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@repo/typescript-config/base.json",
"include": ["src", "*.ts"],
"compilerOptions": {
"lib": ["es2015"]
}
}
3 changes: 0 additions & 3 deletions packages/jest-config/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions packages/jest-config/index.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/jest-config/package.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/storage/jest.config.ts

This file was deleted.

8 changes: 3 additions & 5 deletions packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
"scripts": {
"typecheck": "tsc --noemit",
"lint": "eslint \"**/*.ts\"",
"test": "jest"
"test": "vitest run"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@repo/eslint-config": "workspace:*",
"@repo/jest-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"eslint": "^8.57.0",
"fake-indexeddb": "^6.0.0",
"jest": "^29.7.0",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vitest": "^2.0.5"
},
"dependencies": {
"@repo/types": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/storage/src/db.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from "@jest/globals";
import { test, expect } from "vitest";
import { Activity, db } from "./db";
import { Connection, Pull, PullState, Star } from "@repo/types";

Expand Down
3 changes: 3 additions & 0 deletions packages/storage/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@repo/typescript-config/base.json",
"include": ["src", "*.ts"],
"compilerOptions": {
"lib": ["es2015"]
}
}
7 changes: 7 additions & 0 deletions packages/storage/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
setupFiles: ["fake-indexeddb/auto"],
},
});
Loading

0 comments on commit 1b38ccb

Please sign in to comment.