Netflix / pollyjs

Record, Replay, and Stub HTTP Interactions.
https://netflix.github.io/pollyjs
Apache License 2.0
10.21k stars 352 forks source link

[Question]: Not able to replay the recorded requests #484

Open rochanram opened 1 year ago

rochanram commented 1 year ago

Description

Im recording all the requests for a test and its saved here: ./recordings/iam-login-logout_301619159/recording.har

import { Polly } from "@pollyjs/core";
import NodeHTTP from "@pollyjs/adapter-node-http";
import { MODES } from '@pollyjs/utils';
import FSPersister from '@pollyjs/persister-fs';

Polly.register(NodeHTTP);
Polly.register(FSPersister);

tags(APP, CRITICAL, WEB).describe('IAM - Login and Logout Tests', function () {
  let tempUser;
  before(async function () {
    this.polly = new Polly('iam-login-logout', {
      mode: MODES.REPLAY,
      adapters: ['node-http'],
      persister: 'fs',
      persisterOptions: {
        fs: {
          recordingsDir: './recordings'
        }
      },
      recordIfMissing: true,
      matchRequestsBy: {
        method: true,
        headers: true,
        body: true,
        order: false,
        url: {
            protocol: true,
            username: false,
            password: false,
            hostname: true,
            port: false,
            pathname: true,
            query: true,
            hash: true,
        },
    },
    });
    [tempUser] = await createUser({ type: 'free' });
  });
  it(`should login the users`, async function () {
    await login(tempUser, { goToWorkspace: 'My Workspace' });
  });

  it(`should logout the users`, async function () {
    if (this.polly) {
      this.polly.stop();
    }
    await logout();
  });
});
`

It saves the recordings at : ./recordings/iam-login-logout_301619159/recording.har

But If I run it in replay mode. Its recording again a new file.

When I change it to

recordIfMissing: false,

It shows this error:

[Polly] [adapter:node-http] Recording for the following request is not found and `recordIfMissing` is `false`.
lox commented 1 year ago

I am having exactly the same issue, even when setting everything in matchRequestsBy to false.

Nick-Minutello commented 2 months ago

Not sure about the stop in your tests