Open sambhav-jain-lilly opened 6 months ago
Have a look at the documentation for test framework integration. We had a bit of difficulty getting things working because the documentation & behaviour didn't match.
https://netflix.github.io/pollyjs/#/examples?id=jest-node-fetch https://netflix.github.io/pollyjs/#/examples?id=typescript-jest-node-fetch https://netflix.github.io/pollyjs/#/test-frameworks/jest-jasmine
`import { Polly } from '@pollyjs/core'; import { expect } from 'chai'; // Chai assertion library import FetchAdapter from '@pollyjs/adapter-fetch'; // Fetch adapter for Polly import FSPersister from '@pollyjs/persister-fs'; import NodeHttpAdapter from '@pollyjs/adapter-node-http'; import XHRAdapter from '@pollyjs/adapter-xhr';
// Register adapters and persisters with Polly.js
Polly.register(FetchAdapter); // Register the Fetch adapter Polly.register(FSPersister); Polly.register(NodeHttpAdapter); Polly.register(XHRAdapter);
// Describe a test suite using a testing framework (e.g., Mocha or Jasmine) describe('Simple Example', function () {
// // Stop the Polly instance, which persists recorded requests and disconnects from adapters await polly.stop(); }); });`
I am using this code print request and responses for the above url. My code runs , and it says it is successful but it dosen't show any logs what I am trying to print. I am using mocha for running test. And chai is for assertion. I am not sure whether it is actually intercepting call or not. Can anyone help me with that. Thanks!