Skip to content

Vitest v4 Upgrade #1184

@ktun95

Description

@ktun95

v4 adds visual regression testing, which would allow us to replace playwright.

  1. Remove coverage.all: false (BREAKING CHANGE)

Impact: 23 vitest config files across packages
Files affected: All configs with coverage settings (packages/ui-common, packages/header, packages/navbar, etc.)

The coverage.all option has been removed in v4. Your configs currently use:
coverage: {
include: ["src/*"],
all: false, // ❌ This option no longer exists
}

Action required: Remove the all: false line from all vitest configs. In v4, coverage only includes files loaded
during testing by default (which matches your previous all: false behavior).

Updated config should be:
coverage: {
include: ["src/*"],
// 'all' option removed - v4 default behavior matches old 'all: false'
}

Locations found at:

  • packages/ui-common/vitest.config.ts:18
  • packages/header/vitest.config.ts:12
  • packages/header-mui5/vitest.config.ts:12
  • packages/flex-layout-plugin/vitest.config.ts:12
  • packages/google-analytics/vitest.config.ts:12
  • packages/navbar/vitest.config.ts:13
  • (and 17+ more config files)

Other Breaking Changes (Low/No Impact on Your Codebase)

  1. Default Exclusions Simplified

Vitest v4 now only excludes node_modules and .git by default. Previously excluded patterns (dist, cypress, etc.)
are no longer automatic.

Impact: None detected in your configs
Recommendation: If you rely on default exclusions, consider adding explicit test.exclude patterns

  1. globals: true Remains Valid

Your configs use globals: true extensively. This is still supported in v4, no changes needed.

  1. Mock System Changes
  • vi.fn().getMockName() returns vi.fn() instead of spy (may affect snapshots)
  • invocationCallOrder now starts at 1 instead of 0

Impact: No usage found in your test files
Action: If you have snapshot tests on mocks, they may need updating after migration

Migration Checklist

  1. ✅ Remove coverage.all: false from all 23 vitest.config.ts files
  2. ✅ Update vitest dependency from 3.x to 4.x in all package.json files
  3. ✅ Update @vitest/coverage-v8 from 3.x to 4.x
  4. ⚠️ Run tests after upgrade to check for snapshot failures
  5. ⚠️ Verify coverage reports work as expected

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions