Add test config

This commit is contained in:
2025-11-17 21:59:15 -05:00
parent 8567e67d1a
commit 7d9d0bdf73
8 changed files with 1294 additions and 14 deletions

View File

@@ -24,7 +24,13 @@ export default defineConfig([
ecmaVersion: 2022,
globals: globals.browser,
parserOptions: {
project: ["./tsconfig.json", "./tsconfig.app.json", "./tsconfig.lib.json", "./tsconfig.node.json"],
project: [
"./tsconfig.json",
"./tsconfig.app.json",
"./tsconfig.lib.json",
"./tsconfig.node.json",
"./tsconfig.test.json"
],
tsconfigRootDir: import.meta.dirname
}
},

1235
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,9 @@
"dev": "vite",
"build": "eslint . && tsc -b && vite build",
"lint": "eslint .",
"test": "vitest run",
"test:watch": "vitest",
"coverage": "vitest run --coverage",
"check-git-clean": "git diff --quiet",
"deploy": "npm run check-git-clean && npm run build && npm pack && npm publish --access public",
"preview": "vite preview",
@@ -29,6 +32,9 @@
"@tanstack/react-router": "^1.136.1",
"@tanstack/react-router-devtools": "^1.136.1",
"@tanstack/router-plugin": "^1.136.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/node": "^24.10.1",
"@types/react": "^19.2.4",
"@types/react-dom": "^19.2.3",
@@ -38,11 +44,14 @@
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"jsdom": "^27.2.0",
"rollup-plugin-jsx-remove-attributes": "^3.1.2",
"tailwindcss": "^4.1.17",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.4",
"vite": "^7.2.2",
"vite-plugin-dts": "^4.5.4"
"vite-plugin-dts": "^4.5.4",
"vitest": "^4.0.10"
},
"overrides": {
"@tailwindcss/vite": {

1
test/jest.config.ts Normal file
View File

@@ -0,0 +1 @@
import "@testing-library/jest-dom/vitest";

View File

@@ -3,7 +3,8 @@
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" },
{ "path": "./tsconfig.lib.json" }
{ "path": "./tsconfig.lib.json" },
{ "path": "./tsconfig.test.json" }
],
"compilerOptions": {
"jsx": "react-jsx"

View File

@@ -22,5 +22,5 @@
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
"include": [ "eslint.config.ts", "vite.config.ts"]
}

35
tsconfig.test.json Normal file
View File

@@ -0,0 +1,35 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2022",
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
"baseUrl": ".",
"paths": {
"$/*": [ "./lib/*" ],
"#root": [ "." ]
}
},
"include": [
"lib",
"test"
]
}

View File

@@ -1,7 +1,9 @@
/// <reference types="vitest/config" />
import tailwindcss from "@tailwindcss/vite";
import { tanstackRouter } from "@tanstack/router-plugin/vite";
import react from "@vitejs/plugin-react";
import { resolve } from "path";
import removeTestIdAttribute from "rollup-plugin-jsx-remove-attributes";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import { peerDependencies } from "./package.json";
@@ -24,7 +26,8 @@ export default defineConfig({
compilerOptions: {
declarationMap: false
}
})
}),
removeTestIdAttribute({ usage: "vite" })
],
resolve: {
alias: {
@@ -55,5 +58,11 @@ export default defineConfig({
}
}
},
publicDir: false
publicDir: false,
test: {
globals: true,
root: "test",
environment: "jsdom",
setupFiles: [ "jest.config.ts" ]
}
});