Skip to content

docs: add Karma and Jasmine to the testing guide - #3856

Merged
armando-navarro merged 1 commit into
angular:mainfrom
armando-navarro:docs-testing-guide-karma
Dec 2, 2026
Merged

armando-navarro merged 1 commit into
angular:mainfrom
armando-navarro:docs-testing-guide-karma

Conversation

@armando-navarro

Copy link
Copy Markdown
Collaborator

Checklist

Description

This adds the Karma and Jasmine section that #3855 mentioned would follow. #3050 asks how to mock AngularFire in tests, and its thread has relied on a wrapper-class workaround for Jasmine since 2022.

How I checked it

I pasted every snippet unchanged into apps created with ng new and ran them in headless Chrome:

  • Angular 20 with AngularFire 20.1.1, with the @angular/build:karma builder and with the older @angular-devkit/build-angular:karma
  • Angular 21 with AngularFire 21.0.0 and Angular 22 with 22.0.0-rc.1, both with "runner": "karma"
  • Angular 22 again with zone.js

Then I removed each instruction in turn and confirmed the failure the page describes. For the part on moving to Vitest, I took two of those apps through Angular's migration guide and reran the page's examples.

Fixes #3050

@armando-navarro armando-navarro added bump: patch Size of the change: a fix or docs change that reaches users comp: docs Documentation. type: chore Maintenance with no user-facing behavior change. labels Dec 1, 2026
@armando-navarro armando-navarro added this to the 22.0.0 milestone Dec 1, 2026
@armando-navarro

Copy link
Copy Markdown
Collaborator Author

This will stay a draft until #3855 merges. At that point I'll rebase this branch on main and request a review.

Karma with Jasmine was the Angular CLI's test setup before
Angular 21.

The new section says which of the page's patterns work under
Karma as written, gives the one line the fake Auth example needs
for Jasmine's types, shows two replacements for a module mock,
which Jasmine does not have, and explains why Firebase apps
carry over between spec files. The part on moving to Vitest
gains a path for Karma projects.

Fixes angular#3050

@tyler-reitz tyler-reitz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question on the migration section: "If using @angular/build 21.2, add that file to include in tsconfig.spec.json as well." Is that 21.2 only, or 21.2 and later? If 22 needs it too, "21.2 or later" would say so.

@armando-navarro

armando-navarro commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

@tyler-reitz It's 21.2 only. It's weird, I know. There is a change that was put into 21.2 and it was removed in the next update.

@armando-navarro
armando-navarro merged commit 555fe36 into angular:main Dec 2, 2026
25 checks passed
@armando-navarro
armando-navarro deleted the docs-testing-guide-karma branch December 2, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bump: patch Size of the change: a fix or docs change that reaches users comp: docs Documentation. type: chore Maintenance with no user-facing behavior change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[docs] Mocking of angularfire methods with angularfire 7 during tests

2 participants