vcr 0.2.0 copy "vcr: ^0.2.0" to clipboard
vcr: ^0.2.0 copied to clipboard

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

vcr #

A package to mock requests using Dio Client

Build Status

Getting Started #

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

VcrAdapter adapter = VcrAdapter({basePath:'test/cassettes', createIfNotExists: true });
Dio client = Dio();
client.httpClientAdapter = adapter;

After config the adapter, you now can use a cassette

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

Now the request is stored in test/cassette/users/louis-kevin/repos.json

If you have multiple requests for one test, they will be added in a list of requests If the 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

Options

| basePath | string | Path to store your cassettes, relative to root | | createIfNotExists | boolean | If this is disabled, you need to call useCassette before call your api|

Using useCassette #

The only main difference is that you need to call useCassette before calling your API

adapter.useCassette('github/my_casssete')
Response response = await client.get('https://api.github.com/users/louis-kevin/repos');
expect(response.statusCode, 200);

You can choose passing .json format or not, it will store the cassette in json either way
Now the request is stored in test/cassette/github/my_casssete.json

Next Features

  • ❌ Work with Http Package
  • ❌ Work with YAML
3
likes
0
pub points
26%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, path

More

Packages that depend on vcr