Files
MagicMirror/vitest.config.mjs
Kristjan ESPERANTO cb61aebb5a chore: update ESLint and plugins, simplify config, apply new rules (#4052)
This PR updates ESLint and the ESLint plugins to their latest versions
and takes advantage of the new versions to simplify the config.

The main cleanup: removed all explicit `plugins: {}` registrations from
`eslint.config.mjs`. When passing direct config objects like
`js.configs.recommended`, the plugin registration is already included –
we were just doing it twice.

Two lint warnings are also fixed:
- A wrong import style for `eslint-plugin-package-json` (named vs.
default)
- `playwright/no-duplicate-hooks` is disabled for e2e tests – the rule
doesn't handle plain `beforeAll()`/`afterAll()` (Vitest style) correctly
and produces false positives. I've created an issue for that:
https://github.com/mskelton/eslint-plugin-playwright/issues/443.

Built-in Node.js imports were manually updated to use the `node:` prefix
(e.g. `require("fs")` → `require("node:fs")`). Minor formatting fixes
were applied automatically by `eslint --fix`.
2026-03-07 08:34:28 -07:00

106 lines
2.4 KiB
JavaScript

import {defineConfig} from "vitest/config";
/*
* Sequential execution keeps our shared test server stable:
* - All suites bind to port 8080
* - Fixtures and temp paths are reused between tests
* - Debugging becomes predictable
*
* Parallel execution would require dynamic ports and isolated fixtures,
* so we intentionally cap Vitest at a single worker for now.
*
* Projects separate unit, e2e (Playwright), and electron tests with
* appropriate timeouts for each test type.
*/
export default defineConfig({
test: {
// Shared settings for all test types
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
// Stop test execution on first failure
bail: 3,
// Automatically restore all mocks after each test to prevent leaks
restoreAllMocks: true,
// Shared exclude patterns
exclude: [
"**/node_modules/**",
"**/dist/**",
"tests/unit/mocks/**",
"tests/unit/helpers/**",
"tests/electron/helpers/**",
"tests/e2e/helpers/**",
"tests/e2e/mocks/**",
"tests/configs/**",
"tests/utils/**"
],
// Projects with specific configurations per test type
projects: [
{
test: {
name: "unit",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: [
"tests/unit/**/*_spec.js",
"tests/unit/defaultmodules/calendar/calendar_fetcher_utils_bad_rrule.js"
],
testTimeout: 20000,
hookTimeout: 10000
}
},
{
test: {
name: "e2e",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: ["tests/e2e/**/*_spec.js"],
testTimeout: 60000,
hookTimeout: 30000
}
},
{
test: {
name: "electron",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: ["tests/electron/**/*_spec.js"],
testTimeout: 120000,
hookTimeout: 30000
}
}
],
// Coverage configuration
coverage: {
provider: "v8",
reporter: ["lcov", "text"],
include: [
"clientonly/**/*.js",
"js/**/*.js",
"defaultmodules/**/*.js",
"serveronly/**/*.js"
],
exclude: [
"**/node_modules/**",
"**/tests/**",
"**/dist/**"
]
},
/*
* Pool settings for isolated test execution. Keep maxWorkers at 1 so
* port 8080 and shared fixtures remain safe across the full suite.
*/
pool: "forks",
maxWorkers: 1,
isolate: true
}
});