- Unit Tests (i.e. specs) must be written for every Angular Component or Service. In other words, every "
*.component.ts" file must have a corresponding "
*.component.spec.ts" file, and every "
*.service.ts" file must have a corresponding "
- Integration (e2e) Tests are recommended for new features but not yet required.
- Include tests for different user types (if behaviors differ per user type). This includes testing as (1) an Anonymous user, (2) an Authenticated User (non-Admin), (3) an Administrator and/or Community/Collection Admin (as necessary).
- Include tests for known error scenarios. For example, tests should validate when errors/warnings are expected to appear, and/or validate when buttons are expected to be enabled/disabled.
- Bug fix PRs should include a test that reproduces the bug to prove it is fixed. For clarity, it may be useful to provide the test in a separate commit from the bug fix.
- Art Lowel (Atmire), could you add something here about being careful when writing asynchronous vs synchronous tests? (Is there a good guide we could link to for this?)
Writing Unit (spec) Tests