Closed davemfish closed 1 year ago
We added a minimal test suite in #38 , but I'll leave this open because we'll want to add test coverage.
I think it might be a good time to add a batch of integration tests. There is now enough complexity in the UI, in terms of different pathways the user can take, that it will be a time-save during development to have tests covering those pathways. Up to now, I've basically been trying to manually test all the paths to make sure they work after adding a new feature.
As of #115 we have some basic integration tests, and we have the infrastructure in place to continue to add tests as we develop. So I'll close this issue.
This is one component of #8 . But I wanted a dedicated issue to record notes & discuss just this topic.
Test runners:
Vitest
has been much, much easier to setup thanjest
for this reason:https://vitest.dev/guide/why.html#why-vitest
Test environment (virtual DOM) We need a virtual DOM in order to test & interact with our react components.
jsdom
is the most popular choice.happy-dom
is an alternative. Most comparisons emphasize better performance (query time) forhappy-dom
. Buthappy-dom
also seems to include more of the global browser APIs thanjsdom
(i.e.fetch
), which means we have to do less mocking. That was nice for getting things setup. Ultimately we might not want to make realfetch
calls during tests though. Anyway, these two are easy to switch invite.config.js
.Utilities for querying & interacting with the DOM
@testing-library/*
still seems great for writing integration tests that exercise react components.Special case of testing OpenLayers elements The map renders as a
<canvas>
element. So we can't interact with it using familiar DOM-interaction APIs (i.e.testing-library
oruser-event
). Also the virtual DOMs require some extra configuration to support canvas. (jsdom
can be configured with canvas, I'm not sure abouthappy-dom
).So it might make the most sense to test map interactions using a real browser controlled by
puppeteer
. If we do that, I don't think we need to think much about thecanvas
API, we just execute mouse events, etc.