This repository showcases examples of using Polly.JS to replay pre-recorded HTTP interactions. We demonstrate a fetch call being instantly resolved with the contents of a .har
file, and another fetch call that is intercepted and responded to within JS.
This demonstration assumes you already have Node and NPM installed. The steps are as follows:
- Install node dependencies:
npm install
- Run the application:
npm start
- Observe that requests are replayed and intercepted respectively:
Replayed ➞ GET https://jsonplaceholder.typicode.com/posts/1 200 • 2ms
Intercepted ➞ GET https://made-up-website.com/hello-world 200 • 0ms
- Delete the
recordings/
directory and re-run the application to observe the first request gets recorded (for future replaying):
Recorded ➞ GET https://jsonplaceholder.typicode.com/posts/1 200 • 136ms