Skip to content

docs: add a unit testing guide - #3855

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

armando-navarro merged 2 commits into
angular:mainfrom
armando-navarro:docs-testing-guide

Conversation

@armando-navarro

Copy link
Copy Markdown
Collaborator

Checklist

Description

AngularFire has no testing guidance in docs/ or the README, and #3668 asks for a documented way to unit test code that uses it. This adds docs/testing.md and links it from the README's resource list.

The page covers Vitest, which ng new sets up, and Jest.

How I checked it

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

  • Vitest: Angular 21 with AngularFire 21.0.0 and Angular 22 with 22.0.0-rc.1, each zoneless and with zone.js
  • Jest: Jest 30.5.2 on Angular 21, and Jest 29.7 on Angular 20

Then I removed each instruction in turn and confirmed the failure the page describes. Instructions whose removal changed nothing are not on the page.

A Karma and Jasmine section will follow in its own pull request.

Fixes #3668

AngularFire had no testing guidance in docs/ or the README, and four
issues have asked for it.

docs/testing.md covers Vitest and Jest: real services built from
made-up options, three ways to replace AngularFire in a test, the
setups that do not work with their error text, and the resolver
file Jest 30 needs. The README links to it.

Fixes angular#3668
@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
The hook deletes every Firebase app after each test, including one
created with AngularFireModule.initializeApp. The next test that
calls AngularFireModule.initializeApp then fails with "already
deleted", even with the same options. Measured under Jest and
Vitest.
@armando-navarro
armando-navarro merged commit 4627bab into angular:main Dec 1, 2026
25 checks passed
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.

[Unit Testing] Difficulties with mocking Firebase services in Jest/Angular environment

2 participants