Skip to content

Commit 495671a

Browse files
committed
feat(react): Setup testing
1 parent e2f5d11 commit 495671a

File tree

7 files changed

+392
-59
lines changed

7 files changed

+392
-59
lines changed

packages/firebaseui-react/package.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222
"dev": "tsup --watch",
2323
"lint": "tsc --noEmit",
2424
"format": "prettier --write \"src/**/*.ts\"",
25-
"clean": "rimraf dist"
25+
"clean": "rimraf dist",
26+
"test": "vitest run tests/unit",
27+
"test:watch": "vitest tests/unit",
28+
"test:integration": "vitest run tests/integration",
29+
"test:integration:watch": "vitest tests/integration",
30+
"test:e2e": "vitest run tests/e2e",
31+
"test:e2e:watch": "vitest tests/e2e",
32+
"test:all": "vitest run"
2633
},
2734
"peerDependencies": {
2835
"@firebase-ui/core": "workspace:*",
@@ -40,11 +47,18 @@
4047
"zod": "^3.24.1"
4148
},
4249
"devDependencies": {
50+
"@testing-library/jest-dom": "^6.4.3",
51+
"@testing-library/react": "^16.2.0",
52+
"@types/jsdom": "^21.1.7",
53+
"@types/node": "^22.13.8",
4354
"@types/react": "^19.0.8",
4455
"@types/react-dom": "^19.0.3",
4556
"@vitejs/plugin-react": "^4.3.4",
57+
"jsdom": "^26.0.0",
58+
"tsup": "^8.3.6",
4659
"typescript": "~5.6.2",
4760
"vite": "^6.0.5",
48-
"tsup": "^8.3.6"
61+
"vitest": "^3.0.7",
62+
"vitest-tsconfig-paths": "^3.4.1"
4963
}
5064
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expect } from "vitest";
2+
import * as matchers from "@testing-library/jest-dom/matchers";
3+
4+
// Extend Vitest's expect with jest-dom matchers
5+
expect.extend(matchers);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../tsconfig.test.json",
3+
"include": [
4+
"./**/*.tsx",
5+
"./**/*.ts"
6+
],
7+
"compilerOptions": {
8+
"jsx": "react-jsx",
9+
"esModuleInterop": true,
10+
"types": [
11+
"vitest/globals",
12+
"node",
13+
"@testing-library/jest-dom"
14+
]
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.app.json",
3+
"compilerOptions": {
4+
"jsx": "react-jsx",
5+
"esModuleInterop": true,
6+
"types": [
7+
"vitest/importMeta",
8+
"node",
9+
"@testing-library/jest-dom"
10+
]
11+
},
12+
"include": [
13+
"**/*.ts",
14+
"**/*.tsx"
15+
]
16+
}

packages/firebaseui-react/vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { defineConfig } from "vite";
22
import path from "node:path";
33
import react from "@vitejs/plugin-react";
4-
import tailwindcss from "@tailwindcss/vite";
54

65
// https://vite.dev/config/
76
export default defineConfig({
8-
plugins: [react(), tailwindcss()],
7+
plugins: [react()],
98
resolve: {
109
alias: {
1110
"@firebase-ui/core": path.resolve(__dirname, "../firebaseui-core/src"),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig } from "vitest/config";
2+
3+
export default defineConfig({
4+
test: {
5+
// Use the same environment as the package
6+
environment: "jsdom",
7+
// Include TypeScript files
8+
include: ["tests/**/*.{test,spec}.{js,ts,jsx,tsx}"],
9+
// Exclude build output and node_modules
10+
exclude: ["node_modules/**/*", "dist/**/*"],
11+
// Enable globals for jest-dom to work correctly
12+
globals: true,
13+
// Use tsconfig.test.json for TypeScript
14+
typecheck: {
15+
enabled: true,
16+
tsconfig: "./tsconfig.test.json",
17+
include: ["tests/**/*.{ts,tsx}"],
18+
},
19+
},
20+
});

0 commit comments

Comments
 (0)