Files
BrowserSkill/apps/extension/vitest.config.ts
T
2026-06-22 17:36:26 +08:00

33 lines
1.1 KiB
TypeScript

import { readFileSync } from "node:fs";
import path from "node:path";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
// Mirror wxt.config.ts's version-injection so unit tests see the same
// `__BSK_EXT_VERSION__` define the production build will inline (review
// M3 fix to round-1). Pull from `package.json` once so a release bump
// stays in lockstep across runtime, build, and tests.
const pkg = JSON.parse(readFileSync(path.resolve(__dirname, "package.json"), "utf8")) as {
version: string;
};
export default defineConfig({
plugins: [react()],
test: {
environment: "happy-dom",
include: ["src/**/*.test.ts", "src/**/*.test.tsx"],
globals: false,
setupFiles: ["./src/vitest-setup.ts"],
},
define: {
__BSK_EXT_VERSION__: JSON.stringify(pkg.version),
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@browser-skill/i18n/react": path.resolve(__dirname, "../../packages/i18n/src/react.tsx"),
"@browser-skill/i18n": path.resolve(__dirname, "../../packages/i18n/src/index.ts"),
},
},
});