Tests
Every change needs tests. Write the smallest failing test first, then the smallest change that passes. Cover the happy path, the failure and the edge cases. The PHP tests skill and the Laravel tests skill are the full version.
PHP tests
Unit and functional tests mirror
srcby path undertests/App. Add#[CoversClass(...)].Pick the lightest kind.
- Unit tests need no framework. The file ends in
UnitTest.php. - Functional tests need the container, config or routes. The file ends in
FunctionalTest.php. - Integration tests call an entry point, such as an endpoint, an MCP tool or an Artisan command. They live under
tests/Integration, one entry point per file. The file is named after the entry point and ends inIntegrationTest.php.
- Unit tests need no framework. The file ends in
Name methods
test_it_does_the_thingand describe behavior, not implementation.Structure each test with
// Arrange,// Actand// Assert. Use// Anticipateonly for mock expectations.Resolve the subject with
resolve(). Usenewonly in dependency free unit tests.Prefer
$this->spy()over$this->mock(). Keep every assertion in the assert block.Request routes by name, for example
route('nimbus.api.routes'), and never by a literal URL.Real HTTP calls are blocked. Fake every call.
Never delete or weaken a real test to make a change pass.
Tests that need the framework extend
Sunchayn\Nimbus\Tests\TestCase.
JavaScript tests
- Vitest covers components, stores and composables. See frontend.
- Playwright covers flows in
tests/E2E. The specs run against the workbench.
Running them
Use composer test -- --filter name and npm run test:run -- file while you work. Finish with composer test:parallel. See commands.