daravel_test
English · Bahasa Indonesia
Testing toolkit for Daravel applications, in the spirit of Laravel's testing helpers.
dart pub add dev:daravel_test
import 'package:daravel_test/daravel_test.dart';
import 'package:test/test.dart';
void main() {
final db = refreshDatabase(createApp); // each test rolls back
test('creates a post', () async {
final client = TestClient(db.app).actingAs(await UserFactory().create());
(await client.post('/api/posts', json: {'title': 'Hello'}))
.assertCreated()
.assertJsonPath('data.title', 'Hello');
await assertDatabaseHas('posts', {'title': 'Hello'});
});
}
TestClientwithactingAs,withToken,withHeaders,withoutExceptionHandling, and fluentTestResponseassertions.refreshDatabase,assertDatabaseHas/Missing/Count.- Time travel (
freezeTime,travel,travelTo) over Daravel'sClock. - Architecture checks (
expectRegistryComplete) and lint integration. package:daravel_test/conformance.dart: Laravel 12 wire-format contracts (isLaravelValidationError,isLaravelErrorBody,isLaravelLengthAwarePaginator, Sanctum token format, ...) to prove your API still speaks Laravel.
See example/main.dart and the
testing guide.
License and trademarks
MIT. "Laravel" is a trademark of Laravel Holdings Inc.; "Dart" is a trademark of Google LLC. Daravel is an independent project, not affiliated with or endorsed by either.
Libraries
- conformance
- Laravel 12 conformance contracts (BLUEPRINT_V2 §11.2): fixtures taken from the Laravel and Sanctum sources plus matchers, shared by the framework's conformance suite and by applications that want to verify their API still speaks Laravel's wire format.
- daravel_test
- Testing toolkit for Daravel applications (BLUEPRINT_V2 §7.11).