Feature Testing
Feature tests validate real application behavior through HTTP endpoints and full request lifecycles.
They are the best place to test:
- routes and middleware
- validation and error responses
- authentication and authorization flows
- controller + model integration
Where to place feature tests
Use:
tests/Feature
Feature test setup
Use your project tests/TestCase.ts and call lifecycle hooks around each test.
TypeScript
Request helpers
Available methods from TestCase:
get(uri, headers?)post(uri, data?, headers?)put(uri, data?, headers?)patch(uri, data?, headers?)delete(uri, data?, headers?)
Response assertions
TestResponse supports:
- status assertions:
assertStatus,assertOk,assertCreated,assertForbidden,assertNotFound,assertUnprocessable - payload assertions:
assertJson,assertJsonFragment,assertSee - payload access:
json,text
Generate feature tests
Use ArtisanNode:
Bash
This generates a starter feature test file in tests/Feature.
