Recommended Free Tools
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
To migrate an existing Angular project from Karma and Jasmine to Vitest, first confirm that it uses Angular’s application build system, then install Vitest and a DOM emulator, switch the test target to Angular’s unit-test builder, and review test-specific build settings and custom runner behavior. Only after the runner is configured should you use Angular’s experimental Jasmine-to-Vitest schematic and manually inspect its changes. The migration is optional: Karma remains supported.
Is migrating an existing Angular project to Vitest supported?
Angular’s migration guide says that “Migrating an existing project to Vitest is considered experimental.” The Angular CLI uses Vitest as the default unit test runner for new projects, and the roadmap says Vitest became the primary runner after its stable release in Angular v21. However, the existing-project migration tool is still described as experimental. Angular continues to support Karma, so there is no general requirement to migrate. Angular’s migration guide, testing overview, and roadmap describe this status.
The documented migration path requires the Angular application build system. Check the project’s actual builder and workspace configuration before proceeding; a project using another or legacy build system cannot assume it is eligible for this path.
How do I migrate an existing Angular project from Karma and Jasmine to Vitest?
Treat the migration as two related but separate jobs: configure Angular CLI to run Vitest, then refactor and validate the tests. The schematic handles some source-code conversions, but it does not perform the CLI or build-configuration migration.
#1 Best Overall
-
Confirm the application build system
Inspect the workspace’s build target and confirm that the project uses Angular’s application build system. The migration guide makes this a prerequisite. If it does not, resolve that build-system requirement before relying on the documented migration path. The guide cannot determine eligibility without examining your workspace.
-
Install Vitest and a DOM emulator
Angular’s example installs
vitestandjsdom. The CLI detectshappy-domif it is installed; otherwise, it falls back tojsdom. Choose the emulator that suits the project, and check package versions against the Angular and Node.js compatibility requirements for your environment. The migration page does not enumerate compatible versions.npm install --save-dev vitest jsdomThis is the guide’s example for installing Vitest with jsdom; it is not a version-pinned compatibility recipe.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Switch the Angular test builder
In
angular.json, change the project’s test target builder to@angular/build:unit-test. The builder defaults totsconfig.spec.jsonand the::developmentbuild target. Set these explicitly if your workspace needs different values. Refer to Angular’s migration guide for the configuration example. -
Review test-specific build options
The Karma builder could accept options such as polyfills, assets, and styles directly under the test target; the unit-test builder does not. Compare those test settings with the development build configuration. If they differ, move the test-specific settings into a dedicated build target configuration. If they already match, Angular’s guide says no change is needed. This configuration review is independent of converting Jasmine test syntax. See the migration guide.
-
Audit custom Karma behavior before removing its configuration
Review
karma.conf.jsand any scripts or workspace projects that depend on it. Identify behavior that must be preserved:Rank #3
- Replace Karma reporters with Vitest-compatible alternatives.
- Find equivalent plugins where a Karma plugin provided needed behavior.
- For custom browser launchers, use the Vitest builder’s
browsersoption with an appropriate browser provider. - Coverage is available as an Angular CLI feature through
ng test --coverage.
For custom Vitest configuration, Angular documents using
vitest.config.tsand connecting it throughrunnerConfig. Angular does not directly support the contents of custom configuration or third-party plugins, and may overridetest.projectsandtest.include. Check the migration guide before relying on custom settings.The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Choose Node DOM emulation or real-browser execution
The default runs tests in Node with a DOM emulator, so it does not launch a browser. If tests need real-browser behavior, install a provider and configure
browserson the test target. Angular’s examples include Playwright for Chromium, Firefox, and WebKit; WebdriverIO for Chrome, Firefox, Safari, and Edge; and a preview provider for WebContainer environments. Confirm that a provider currently supports your required browser and project constraints before choosing it.The CLI enables headless mode when the
CIenvironment variable is set or a browser name includes “Headless”; otherwise, it runs headed. See Angular’s migration guide and test command reference.Rank #4
-
Run the experimental Jasmine refactoring schematic
After configuring the Vitest builder, run:
ng g @schematics/angular:refactor-jasmine-vitestThe schematic converts common patterns, including
fit/fdescribeto.only,xit/xdescribeto.skip,spyOntovi.spyOn, selected Jasmine matchers and spy factories to Vitest APIs, lifecycle hooks, andfail()tovi.fail(). It adds TODOs for patterns it cannot convert.Use options such as
--project,--include,--file-suffix,--add-imports,--verbose, or--browser-modewhen they fit the workspace and desired refactor. Consult Angular’s guide for option details.Free tools Windows power users keep installed
One-click scans. No signup required.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Manually review and finish the migration
The schematic does not install dependencies, edit
angular.json, migrate build options, deletekarma.conf.jsortest.ts, or fully handle complex or nested spy scenarios. Review every change, paying particular attention to spies and mocks, and resolve the TODOs. Then remove old setup files and Karma/Jasmine packages only after confirming no scripts or other projects still use them. Angular’s uninstall command is an example for a newly generated CLI project, not a complete package list for every workspace.Best Value
-
Run the suite and fix remaining failures
Run
ng testand address failures manually; the schematic does not guarantee that all tests will pass. Interactive runs use watch mode by default, while CI behavior differs. Use Angular’s CLI reference for command behavior and the migration guide for migration-specific direction.
What should I do about Zone.js test utilities?
If existing tests depend on fakeAsync, flush, or waitForAsync, Angular documents adding zone.js/plugins/vitest-patch to the test target’s polyfills. Treat this as a compatibility bridge, not as a guarantee that all Zone.js behavior is identical under Vitest. Angular recommends planning a move toward native async patterns and Vitest fake timers. See the migration guide.
Which migration approach fits the project?
- Build-system readiness: the documented migration requires Angular’s application build system. If the workspace does not use it, this path is not ready to apply as written.
- Browser requirements: a DOM emulator runs in Node without launching a browser; tests that require real browser execution need a provider and browser configuration.
- Custom Karma behavior: numerous custom reporters, plugins, or launchers mean more manual mapping and validation before old configuration can be removed.
- Zone.js reliance: tests using Zone.js utilities can use Angular’s documented patch, but teams should plan for native async and Vitest timers.
- Refactor effort: common Jasmine patterns can be converted by the experimental schematic, while complex spies, mocks, and unrecognized patterns need manual attention.
Angular’s cited guidance provides no migration success rate or benchmark figures, so it does not establish a speed improvement for a particular project.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

