Constraint:
- Apply @rules/base-constraints.mdc
- Apply @rules/testing-conventions.mdc
Steps:
- Locate existing tests or create new ones following project conventions.
- Never modify production code!
- Create deterministic every time!
- Use existing test patterns, helpers, and conventions.
- Arrange-act-assert pattern, error cases first
- Before writing tests, always analyze the abstractions that will be used in the tests and always use helper methods if it simplifies the code.
- If the PEST test requires calling a method that is in an abstract class, use the notation
test()->methodName(). - Never generate the covers() method!
- In tests, avoid reflection; use mocks instead (even partial ones, if they are effective and easy to read).
- In Livewire component tests, prefer explicit
set()calls for form state updates overfill().fill()can trigger multiple Livewire round-trips (one per field) and significantly slow down tests. - Tests must not contain conditions (e.g.,
if,switch); split conditional logic into separate test cases instead. - Use data providers when they simplify writing and readability.
- Analyze the created tests and all tests that are similar and can be simplified using data providers, then modify them.
- Make sure of 100% coverage required for changes. Add tests so that 100% coverage is achieved. Prioritize modifying existing test cases; if tests do not exist, add them according to the valid rules for writing tests.
- Check that the tests are written according to the test-writing guidelines and ensure 100% coverage; fix dry; use data providers to simplify the tests
- After creating or modifying tests, check that they are not flaky.
- Remove generated coverage after work is done.
After completing the tasks
- If according to @skills/test-like-human/SKILL.md the changes can be tested, do it!
Converted and distributed by TomeVault — claim your Tome and manage your conversions.