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

Unit tests should validate against msw pact adapter #8

Open
iainsproat opened this issue Mar 24, 2023 · 1 comment
Open

Unit tests should validate against msw pact adapter #8

iainsproat opened this issue Mar 24, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@iainsproat
Copy link
Contributor

What package are you referring to?

Unit tests which perform API calls (currently mocked by msw).

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

Keeping the server API and the client's expectation of the API in sync is difficult, and often leads to breaking changes in one which are not reflected in another.

Our tests are against a mocked server, and expectations of requests and responses are independent of the tests that are run when validating the actual server.

Describe the solution you'd like

This is a problem that Pact solves.

We should use Pact's msw adapter to replace our mocked server responses, and generate Pact files. These files can be similarly run against our server when performing its API tests.

Describe alternatives you've considered

Additional context

Related issues or community discussions

@iainsproat iainsproat added enhancement New feature or request question Further information is requested and removed question Further information is requested labels Mar 24, 2023
@iainsproat
Copy link
Contributor Author

This generates pact files based on interactions, but doesn't provide a convenient way to allow the pact files to be loaded a subsequent time to verify the interactions have not changed.
We could do this with pre-commit, by running the test, saving the files, and then determining if any files were changed.
Or we could manually load the files, and compare against the adapter's output - similar to this in-memory comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant