spookie 1.0.2+1 copy "spookie: ^1.0.2+1" to clipboard
spookie: ^1.0.2+1 copied to clipboard

SuperAgent driven library for testing Dart HTTP servers.

spookie 🎌 #

I wrote this to work just like https://www.npmjs.com/package/supertest

Installing: #

In your pubspec.yaml

dev_dependencies:
  spookie: ^1.0.1

Basic Usage: #

You can use spookie to test any framework or library that uses the Dart HttpServer underneath.

Your class just need to have a handleRequest method that accepts an HttpRequest type object.

Example testing of Pharaoh using spookie

import 'package:pharaoh/pharaoh.dart';
import 'package:spookie/spookie.dart';

void main() async {

   test('should not override previous Content-Types', () async {
      final app = Pharaoh().get('/', (req, res) {
        return res
            .type(ContentType.parse('application/vnd.example+json'))
            .json({"hello": "world"});
      });

      await (await request<Pharaoh>(app))
          .get('/')
          .expectStatus(200)
          .expectContentType('application/vnd.example+json')
          .expectBody('{"hello":"world"}')
          .test();
    });

}

Tests #

The cases in the spookie_test.dart are also used for automated testing. So if you want
to contribute or just make sure that the package still works, simply run:

dart test
3
likes
0
points
4
downloads

Publisher

verified publisheryaroo.dev

Weekly Downloads

SuperAgent driven library for testing Dart HTTP servers.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http, test

More

Packages that depend on spookie