Files
galaxy/client/vitest.config.mts
T
Dannon Baker a5667572fb Tidy vitest config after winbox removal
Drop the stray blank line where 'winbox' lived, and let prettier sort
the imports while we're here.
2026-04-30 23:10:29 -05:00

92 lines
3.0 KiB
TypeScript

/// <reference types="vitest" />
import vue from "@vitejs/plugin-vue2";
import path from "path";
import { fileURLToPath } from "url";
import { defineConfig } from "vite";
import { i18nPlugin } from "./tests/vitest/test-plugin";
import { yamlPlugin } from "./tests/vitest/yaml-plugin";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// List of modules that need to be transformed
const modulesToTransform = [
"axios",
"bootstrap-vue",
"rxjs",
"@hirez_io",
"pretty-bytes",
"@fortawesome",
"ro-crate-zip-explorer",
"yaml",
];
export default defineConfig({
plugins: [vue(), i18nPlugin(), yamlPlugin()],
test: {
globals: false,
environment: "happy-dom",
setupFiles: ["./tests/vitest/setup.ts"],
environmentOptions: {
happyDOM: {
url: "http://localhost/",
},
},
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
exclude: [
"node_modules/",
"tests/",
"dist/",
"**/*.d.ts",
"**/*.test.{js,ts}",
"**/mock*.{js,ts}",
"**/__mocks__/",
],
},
// Transform modules that need it
server: {
deps: {
inline: modulesToTransform,
},
},
// Use thread pool for faster test execution
pool: "threads",
// Test file patterns
include: ["src/**/*.test.{js,ts}", "tests/vitest/**/*.test.{js,ts}"],
// Exclude patterns
exclude: ["node_modules", "dist", "**/dist/**"],
},
resolve: {
alias: {
// Match former Jest's module name mapping
"@": path.resolve(__dirname, "./src"),
"@tests": path.resolve(__dirname, "./tests"),
config: path.resolve(__dirname, "./tests/vitest/__mocks__/config.js"),
config$: path.resolve(__dirname, "./tests/vitest/__mocks__/config.js"),
"utils/localization$": path.resolve(__dirname, "./tests/vitest/__mocks__/localization.js"),
"viz/trackster$": path.resolve(__dirname, "./tests/vitest/__mocks__/trackster.js"),
// Handle i18n imports
"^i18n!(.*)": path.resolve(__dirname, "./tests/vitest/__mocks__/localization.js"),
// Handle handsontable
handsontable: "handsontable/dist/handsontable.js",
// Handle rxjs scheduler
"rxjs/internal/scheduler/AsyncScheduler": "rxjs/dist/esm/internal/scheduler/AsyncScheduler.js",
},
// Ensure .vue files are resolved
extensions: [".js", ".ts", ".json", ".vue", ".yml", ".txt"],
},
// CSS handling
css: {
modules: {
// Mock CSS modules like Jest does
generateScopedName: "[local]",
},
},
// Build optimizations for test mode
optimizeDeps: {
include: ["vue", "@vue/test-utils", ...modulesToTransform],
},
});