vcr2 1.0.0 copy "vcr2: ^1.0.0" to clipboard
vcr2: ^1.0.0 copied to clipboard

A package to mock requests in tests, storing request in json files and reusing

vcr2 #

A package to mock requests using Dio Client, supports nullsafety. Forked from the original vcr & maintained, it's a drop-in replacement.

Getting Started #

To start using, just create a adapter and put inside your client
This is a example with Dio client:

VcrAdapter adapter = VcrAdapter();
Dio client = Dio();
client.httpClientAdapter = adapter;

After config the adapter, you now can use a cassette

adapter.useCassette('github/user_repos');

Response response = await client.get('https://api.github.com/users/keviinlouis/repos');
expect(response.statusCode, 200);

Now the request is stored in test/cassette/github/user_repos.json

If you have multiple requests for one test, they will be added in a list of requests If de adapter can't find the right request, he will make a normal request and then store the request

This package is inspired by VCR gem

Next Features

  • Work with Http Package
0
likes
80
pub points
0%
popularity

Publisher

unverified uploader

A package to mock requests in tests, storing request in json files and reusing

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dio, flutter

More

Packages that depend on vcr2