specklesystems / speckle-automate-github-action

GitHub Action for creating Speckle Automate Functions
Apache License 2.0
3 stars 2 forks source link

Unit tests should validate against msw pact adapter #8

Open iainsproat opened 1 year ago

iainsproat commented 1 year ago

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 commented 1 year ago

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.