Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#484·pollyjs

[Question]: Not able to replay the recorded requests

Author: rochanramCreated Aug 10, 2023Updated Jun 26, 2024

Description

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

javascript
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`.

Source: Netflix/pollyjs

View original on GitHubView discussion on GitHub