mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-12-12 01:42:19 +00:00
[tests] migrate from jest to vitest (#3940)
This is a big change, but I think it's a good move, as `vitest` is much more modern than `jest`. I'm excited about the UI watch feature (run `npm run test:ui`), for example - it's really helpful and saves time when debugging tests. I had to adjust a few tests because they had time related issues, but basically we are now testing the same things - even a bit better and less flaky (I hope). What do you think?
This commit is contained in:
committed by
GitHub
parent
b542f33a0a
commit
462abf7027
70
vitest.config.mjs
Normal file
70
vitest.config.mjs
Normal file
@@ -0,0 +1,70 @@
|
||||
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.
|
||||
*/
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
// Global settings
|
||||
globals: true,
|
||||
environment: "node",
|
||||
// Setup files for require aliasing
|
||||
setupFiles: ["./tests/utils/vitest-setup.js"],
|
||||
// Increased from 20s to 60s for E2E tests, 120s for Electron tests
|
||||
testTimeout: 120000,
|
||||
// Increase hook timeout for Electron cleanup
|
||||
hookTimeout: 30000,
|
||||
// Stop test execution on first failure
|
||||
bail: 1,
|
||||
|
||||
// File patterns
|
||||
include: [
|
||||
"tests/**/*_spec.js",
|
||||
// Legacy regression test without the _spec suffix
|
||||
"tests/unit/modules/default/calendar/calendar_fetcher_utils_bad_rrule.js"
|
||||
],
|
||||
exclude: [
|
||||
"**/node_modules/**",
|
||||
"**/dist/**",
|
||||
"tests/unit/mocks/**",
|
||||
"tests/unit/helpers/**",
|
||||
"tests/electron/helpers/**",
|
||||
"tests/e2e/helpers/**",
|
||||
"tests/e2e/mocks/**",
|
||||
"tests/configs/**",
|
||||
"tests/utils/**"
|
||||
],
|
||||
|
||||
// Coverage configuration
|
||||
coverage: {
|
||||
provider: "v8",
|
||||
reporter: ["lcov", "text"],
|
||||
include: [
|
||||
"clientonly/**/*.js",
|
||||
"js/**/*.js",
|
||||
"modules/default/**/*.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
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user