Commit graph

3 commits

Author SHA1 Message Date
Ondrej Ezr
78bc71fe6a Allow launch wizard for Azure images 2023-03-29 12:11:14 +02:00
lucasgarfield
8adfd793d6 Jest: Add mock service worker server commands to jest.setup.js
This commit makes the `msw` server globally available to all test files.
Given that the majority of our test files will ultimately make calls to
APIs using RTK Query (calls are made in both the table and the wizard),
making these globally available in jest.setup.js is reasonable.
2023-02-22 16:26:15 +01:00
lucasgarfield
6fd2a04292 Jest: Polyfill fetch and Request
We are migrating towards using RTK Query for API calls, and using `msw`
to mock APIs in our tests.

RTK Query's `fetchBaseQuery` requires the use of `fetch` and `Request`.

`fetch()` was added to Node in v18, and the ability to use it in
Jest tests was added to Jest in v28. However, it still cannot be used
with a `jsdom` test environment.

Therefore, it is necessary to add a polyfill. There are several
libraries available for this but many others in this situation have had
success using `whatwg-fetch` and so it was selected somewhat
arbitrarily.

It is also important that `whatwg-fetch` is imported before
`fetchBaseQuery` (otherwise, a nuisance console warning will be issued).
To ensure this happens, it is imported in a Jest setup file.
2023-02-15 09:23:24 +01:00