vcr

Creator: coderz1093

Last updated:

0 purchases

vcr Image
vcr Images

Languages

Categories

Add to Cart

Description:

vcr

vcr #
A package to mock requests using Dio Client


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;
copied to clipboard
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);
copied to clipboard
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



option
type
description
default




basePath
string
Path to store your cassettes, relative to root
test/cassettes


createIfNotExists
boolean
If this is disabled, you need to call useCassette before call your api
true



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);
copied to clipboard
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

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.