Skip to main content

daravel_test 1.6.0 copy "daravel_test: ^1.6.0" to clipboard
daravel_test: ^1.6.0 copied to clipboard

Testing toolkit for Daravel applications (TestClient, assertions, database helpers, fakes, time travel, architecture checks).

Daravel

daravel_test #

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'});
  });
}
  • TestClient with actingAs, withToken, withHeaders, withoutExceptionHandling, and fluent TestResponse assertions.
  • refreshDatabase, assertDatabaseHas / Missing / Count.
  • Time travel (freezeTime, travel, travelTo) over Daravel's Clock.
  • 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.

0
likes
160
points
--
downloads

Documentation

Documentation
API reference

Publisher

verified publisherdaravel.teoprayoga.my.id

Weekly Downloads

Testing toolkit for Daravel applications (TestClient, assertions, database helpers, fakes, time travel, architecture checks).

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#testing #server #http #backend #database

License

MIT (license)

Dependencies

collection, daravel, daravel_lints, path, test

More

Packages that depend on daravel_test