vitest.config.ts•3.29 kB
import { defineConfig } from "vitest/config";
import path from "node:path";
const GLOBAL_IGNORED_FILES = [
"tmp/**",
"node_modules/**",
"dist/**",
"**/node_modules/**",
];
// Detect if running in CI environment
const isCI = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';
export default defineConfig({
resolve: {
alias: [
// Runtime alias for the new package entry
{
find: "@internal/code-indexer",
replacement: path.resolve(
__dirname,
"packages/code-indexer/src/index.ts",
),
},
{
find: "@internal/lsp-client",
replacement: path.resolve(
__dirname,
"packages/lsp-client/src/index.ts",
),
},
{
find: "@internal/types",
replacement: path.resolve(__dirname, "packages/types/src/index.ts"),
},
// Alias to access repo root src as "lsmcp/*" from packages
{
find: /^lsmcp\//,
replacement: path.resolve(__dirname, "src/") + "/",
},
],
},
test: {
exclude: GLOBAL_IGNORED_FILES,
poolOptions: {
minThreads: 2,
maxThreads: 6,
},
setupFiles: ["./tests/setup.ts"],
projects: [
{
extends: true,
test: {
name: "unit",
includeSource: ["src/**/*.ts", "packages/**/*.ts"],
include: [
"src/**/*.test.ts",
"packages/**/*.test.ts",
"tests/unit/**/*.test.ts",
],
exclude: [
...GLOBAL_IGNORED_FILES,
// These files contain LSP integration tests that should not run as unit tests
"src/tools/lsp/definitions.ts",
"src/tools/lsp/diagnostics.ts",
"src/tools/lsp/hover.ts",
"src/tools/lsp/references.ts",
// Exclude moved tool files
"packages/lsp-client/src/tools/**/*.ts",
],
},
},
{
extends: true,
test: {
name: "integration",
include: ["tests/integration/**/*.test.ts", "tests/*.test.ts"],
exclude: [
...GLOBAL_IGNORED_FILES,
"tests/integration/typescript-lsp.test.ts",
],
testTimeout: isCI ? 30000 : 10000, // Longer timeout in CI
// Retry flaky tests up to 2 times due to timing-sensitive LSP operations
retry: isCI ? 3 : 2,
},
},
{
extends: true,
test: {
name: "languages",
include: ["tests/languages/**/*.test.ts"],
exclude: [...GLOBAL_IGNORED_FILES],
testTimeout: isCI ? 30000 : 15000, // Longer timeout in CI for language initialization
retry: 0, // No retry for language tests
},
},
{
extends: true,
test: {
name: "bench",
include: ["src/**/*.bench.ts"],
exclude: [...GLOBAL_IGNORED_FILES],
benchmark: {
outputFile: "./bench-results.json",
},
},
},
{
extends: true,
test: {
name: "lsp-client",
include: ["packages/lsp-client/**/*.test.ts"],
exclude: [...GLOBAL_IGNORED_FILES],
testTimeout: isCI ? 30000 : 10000,
},
},
],
},
});