Skip to content

docs: Extend TypeScript example#464

Open
justsml wants to merge 4 commits intoNetflix:masterfrom
justsml:extend-typescript-example
Open

docs: Extend TypeScript example#464
justsml wants to merge 4 commits intoNetflix:masterfrom
justsml:extend-typescript-example

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