Skip to content

docs: add testing tips to AGENTS.md#67041

Open
mmalerba wants to merge 5 commits intoangular:mainfrom
mmalerba:agents
Open

docs: add testing tips to AGENTS.md#67041
mmalerba wants to merge 5 commits intoangular:mainfrom
mmalerba:agents

Conversation

@mmalerba
Copy link
Contributor

Add testing tips to AGENTS.md

@pullapprove pullapprove bot requested a review from josephperrott February 12, 2026 17:39
@angular-robot angular-robot bot added the area: docs Related to the documentation label Feb 12, 2026
@ngbot ngbot bot added this to the Backlog milestone Feb 12, 2026
@mmalerba mmalerba added the target: patch This PR is targeted for the next patch release label Feb 12, 2026
@mmalerba mmalerba requested a review from atscott February 12, 2026 18:21
Add testing tips to AGENTS.md
@mmalerba mmalerba requested a review from atscott February 12, 2026 23:43
Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

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

I tested this out by converting the contents of packages/core/test/acceptance/control_flow_for_spec.ts to an outline, then asking gemini to create the tests. It stuck to the old detectChanges style and I asked why and iterated on the agents file from there. I think this gave better outcomes:

## Testing

- **Zoneless & Async-First:** Assume a zoneless environment where state changes schedule updates asynchronously.
  - **Do NOT** use `fixture.detectChanges()` to manually trigger updates.
  - **ALWAYS** use the "Act, Wait, Assert" pattern:
    1. **Act:** Update state or perform an action.
    2. **Wait:** `await fixture.whenStable()` to allow the framework to process the scheduled update.
    3. **Assert:** Verify the output.
- To keep tests fast, minimize the need for waiting:
   - Use `useAutoTick()` (from `packages/private/testing/src/utils.ts`) to fast-forward time via the mock clock.
 - When waiting is necessary, use real async tests (`it('...', async () => { ... })`) along with:
   - `await timeout(ms)` (from `packages/private/testing/src/utils.ts`) to wait a specific number of milliseconds.
   - `await fixture.whenStable()` to wait for framework stability.

I do think this misses the nuance of whenStable not working in all scenarios but that is probably fine for most use-cases.

@mmalerba
Copy link
Contributor Author

yeah I also found it difficult to get it away from fixture.detectChanges() without explicitly telling it not to

@mmalerba mmalerba requested a review from atscott February 13, 2026 00:29
Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Joey Perrott <josephperrott@gmail.com>
@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Feb 13, 2026
@ngbot
Copy link

ngbot bot commented Feb 13, 2026

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "pullapprove" is failing
    pending 2 pending code reviews

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@mattrbeck mattrbeck removed the request for review from atscott February 13, 2026 23:02
@mattrbeck
Copy link
Member

@atscott This is still in a state of "requested changes" but Miles added the merge label. Are your requests required to merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: docs Related to the documentation target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants