mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-28 05:12:33 +00:00
- Updated ESLint configuration to include unit test files with TypeScript and JSX support. - Modified tsconfig.json to include test files for better type checking. - Added a new tsconfig.unit.json for unit tests, specifying necessary types and includes. - Adjusted vitest.config.ts to include the new test file patterns for comprehensive testing coverage.
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
const configDir = path.dirname(fileURLToPath(import.meta.url));
|
|
const projectRoot = path.resolve(configDir, "..");
|
|
|
|
export default defineConfig({
|
|
root: projectRoot,
|
|
plugins: [
|
|
nodePolyfills({
|
|
include: ["buffer", "process", "util", "os", "crypto", "stream"],
|
|
globals: {
|
|
Buffer: true,
|
|
process: true,
|
|
global: true,
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
buffer: "buffer",
|
|
process: "process/browser",
|
|
util: "util",
|
|
os: "os-browserify/browser",
|
|
},
|
|
},
|
|
test: {
|
|
globals: true,
|
|
environment: "jsdom",
|
|
maxWorkers: 1,
|
|
minWorkers: 1,
|
|
// Clear call history between tests but keep mock implementations from setup.ts
|
|
// (mockReset/restoreMocks wipe vi.fn implementations and break shared mocks like getBackendUrl).
|
|
clearMocks: true,
|
|
mockReset: false,
|
|
restoreMocks: false,
|
|
setupFiles: ["src/test/setup.ts"],
|
|
include: ["src/**/*.test.{ts,tsx}", "test/*.test.{ts,tsx}"],
|
|
hookTimeout: 30000,
|
|
testTimeout: 30000,
|
|
coverage: {
|
|
provider: "v8",
|
|
include: ["src/**/*.{ts,tsx}"],
|
|
exclude: [
|
|
"src/main.tsx",
|
|
"src/vite-env.d.ts",
|
|
"src/**/*.d.ts",
|
|
"src/test/**",
|
|
"src/__tests__/**",
|
|
"src/**/__tests__/**",
|
|
"src/**/*.test.{ts,tsx}",
|
|
"src/**/types.ts",
|
|
"src/**/types/*.ts",
|
|
"src/types/**",
|
|
],
|
|
reporter: ["text", "text-summary", "html", "lcov"],
|
|
// thresholds: {
|
|
// lines: 15,
|
|
// statements: 15,
|
|
// functions: 15,
|
|
// branches: 12,
|
|
// },
|
|
},
|
|
},
|
|
});
|