mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
ee7b4eb24d
Add testing tips to AGENTS.md
1.6 KiB
1.6 KiB
trigger
| trigger |
|---|
| always_on |
This is the source code for the Angular framework. This guide outlines standard practices for AI agents working in this repository.
Environment
- Use
pnpmfor package management. - Use
pnpm bazel test //targetto run tests.
Key Documentation
- Building and Testing: definitive guide for running targets.
- Coding Standards: style guide for TypeScript and other files.
- Commit Guidelines: format for commit messages and PR titles.
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:
- Act: Update state or perform an action.
- Wait:
await fixture.whenStable()to allow the framework to process the scheduled update. - Assert: Verify the output.
- Do NOT use
- To keep tests fast, minimize the need for waiting:
- Use
useAutoTick()(frompackages/private/testing/src/utils.ts) to fast-forward time via the mock clock.
- Use
- When waiting is necessary, use real async tests (
it('...', async () => { ... })) along with:await timeout(ms)(frompackages/private/testing/src/utils.ts) to wait a specific number of milliseconds.await fixture.whenStable()to wait for framework stability.
Pull Requests
- Use the
ghCLI (GitHub CLI) for creating and managing pull requests.