Skip to content

Proposal: integrate MSW with Pact (pact.io) #572

@mefellows

Description

@mefellows

Is your feature request related to a problem? Please describe.

Mocking APIs makes is preferable to end-to-end integration testing, because mocking enables:

  • Fast feedback
  • Requires fewer dependencies
  • Does not need a dedicated test environment
  • Reliable (not flakey) tests
  • Simple debugging

You create sets of unit tests on either side of a boundary:

Screen Shot 2021-02-01 at 10 15 41 am

The problem with mocking APIs, is that you don't have confidence that your mocks are genuine representations of reality, and can lead to integration issues elsewhere (e.g. in production):

Screen Shot 2021-02-01 at 10 15 31 am

Describe the solution you'd like

Pact is a tool that uses a process known as consumer-driven contract-testing to capture the expectations from the API consumer, and replay them against the API provider to ensure these mocks are kept in sync. By using MSW as the capture mechanism (replacing the existing consumer test process) and serialising them into a Pact compatible contract (as defined by the Pact specification), we could use MSW with confidence knowing the mocks don't drift from reality.

Describe alternatives you've considered
n/a

Additional context

As discussed at the recent TestJS Summit

Screen Shot 2021-02-01 at 9 53 40 am

Opening up for conversation here.

cc: @bethesque @rholshausen

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions