Files
Folo/apps/desktop/layer/renderer/vitest.config.ts
T
Innei 0b92079dd0 fix(testing): add aliases for package and locales in vitest configuration
- Introduced alias mappings for "@pkg" pointing to the package.json file and "@locales" pointing to the locales directory.
- This enhancement simplifies module resolution and improves code organization in the renderer layer.

Signed-off-by: Innei <tukon479@gmail.com>
2025-05-16 00:11:11 +08:00

42 lines
1.0 KiB
TypeScript

import { readFileSync } from "node:fs"
import { resolve } from "node:path"
import { fileURLToPath } from "node:url"
import tsconfigPath from "vite-tsconfig-paths"
import { defineProject } from "vitest/config"
import { astPlugin } from "../../plugins/vite/ast"
const pkg = JSON.parse(readFileSync("package.json", "utf8"))
const __dirname = fileURLToPath(new URL(".", import.meta.url))
export default defineProject({
root: "./",
test: {
globals: true,
setupFiles: [resolve(__dirname, "./setup-file.ts")],
environment: "happy-dom",
alias: {
"@pkg": resolve(__dirname, "./package.json"),
"@locales": resolve(__dirname, "../../../../locales"),
},
},
define: {
APP_VERSION: JSON.stringify(pkg.version),
APP_NAME: JSON.stringify(pkg.name),
APP_DEV_CWD: JSON.stringify(process.cwd()),
GIT_COMMIT_SHA: "'SHA'",
DEBUG: process.env.DEBUG === "true",
ELECTRON: "false",
},
plugins: [
astPlugin,
tsconfigPath({
projects: ["./tsconfig.json"],
}),
],
})