nock-utils
Utility tools to simplify recording and playing back http requests during tests
Quick Example
const nockUtils = ;const recorder = 'cassette.json';recorderstart; // Call http requests here. recorder;
Complete Example
// Import nock-utilsconst nockUtils = ;const rest = ; // Instantiate HttpRecorder passing the cassette location.const recorder = 'cassette.json';const startTime = ; // If cassette.json DOES NOT exist it will start recording all http transactions.// If cassette.json DOES exist it will playback http requests contained in the cassette.recorderstart; ;
Testing all mocks ran
You can validate all mocks were executed by passing a true to the nock.stop
method:
async { recorderstart; await ; recorder; // This will throw if the cassette had more mocks than just that request.}
Installation
With npm:
$ npm install --save-dev nock-utils
With yarn:
$ yarn add --dev nock-utils
License
This project is licensed under the MIT License - see the LICENSE file for details