Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Extend TypeScript example #464

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

justsml
Copy link
Contributor

@justsml justsml commented Jun 8, 2022

After using my original example (#440) a bit more in production, I've found it super handy to be able to pass in config overrides per test file.

Description

Now you can invoke the helper like so:

Example: Ignoring headers (API Keys)

const polly = autoSetupPolly({
  matchRequestsBy: {
    headers: { exclude: ['x-request-id', 'x-api-key'] },
  }
});

Example: Ignoring generated data using a callback

const polly = autoSetupPolly({
 matchRequestsBy: {
   body(body, req) {
     const json = JSON.parse(body);

     delete json.uuid;
     delete json.createdDate;

     return JSON.stringify(json);
   }
});

Motivation and Context

Sharing my improved code back upstream ❤️

Types of Changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My code follows the code style of this project.
  • My commits and the title of this PR follow the Conventional Commits Specification.
  • I have read the contributing guidelines.

@justsml justsml changed the title Extend TypeScript example docs: Extend TypeScript example Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant