https://github.com/phpjuice/pest-plugin-vcr
Integrates Pest with PHP-VCR
https://github.com/phpjuice/pest-plugin-vcr
pest pest-vcr php-vcr vcr
Last synced: 9 months ago
JSON representation
Integrates Pest with PHP-VCR
- Host: GitHub
- URL: https://github.com/phpjuice/pest-plugin-vcr
- Owner: phpjuice
- License: mit
- Created: 2021-08-27T23:12:30.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-30T14:34:12.000Z (over 4 years ago)
- Last Synced: 2025-06-09T15:05:37.237Z (10 months ago)
- Topics: pest, pest-vcr, php-vcr, vcr
- Language: PHP
- Homepage: https://phpjuice.github.io/pest-plugin-vcr
- Size: 45.9 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Pest plugin for PHP-VCR

[](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
Integrates Pest with [PHP-VCR](http://php-vcr.github.io) using plugins.
## Installation
You can install the package via composer:
```bash
composer require phpjuice/pest-plugin-vcr --dev
```
## Setup
Add new folder inside tests to store cassettes:
```bash
mkdir tests/cassettes
```
Add the following line to your `Pest.php` file, this will tell
VCR where to look for `cassettes`:
```php
use VCR\VCR;
VCR::configure()->setCassettePath(__DIR__.'/cassettes');
```
## Usage
This plugin will provide you with two handy functions `vcrTurnOn` & `vcrTurnOff` to turn on and off the http recording :
```php
it('records requests to pestphp.com', function () {
vcrTurnOn('pestphp.com');
$result = file_get_contents('https://pestphp.com/');
expect($result)
->toBe('Hello from pestphp.');
vcrTurnOff();
});
```
The previous testsuite, will first send a request to `pestphp.com` and
Record your test suite's HTTP interactions into a cassette and replay them
during future test runs for fast, deterministic, accurate tests.
> **Important** before running your tests make sure to have the following folder `tests/cassettes`
### Testing
```bash
composer test
```
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, send us an email to phpjuice@gmail.com instead of using the issue tracker.
## Credits
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## PHP Package Boilerplate
This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com) by [Beyond Code](http://beyondco.de/).

[](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[](https://packagist.org/packages/phpjuice/pest-plugin-vcr)
[](https://packagist.org/packages/phpjuice/pest-plugin-vcr)