With the recent integration of BlockNote (in React) inside of Cristal, we now need a solid test suite to ensure everything works fine across browsers and that we don’t have any regression going forward.
Given we obviously can’t use the same test tools as we do with Vue, we need to decide on a testing library for unit tests, end-to-end tests being performed with Playwright.
After some testing I’m proposing to use Playwright as well for end-to-end tests. using the components support.
Pros:
- One single testing library for both unit and end-to-end tests
- Avoiding introducing another, different testing library inside Cristal
Cons:
- Components support is still experimental
I have also tried testing-library
, which seems a bit more convoluted to set up and has (IMO) a less nice API:
- Renders are done globally instead of per-instance, e.g. you don’t render your component through
const component = mount(<Component />)
and then interact with it, but directly callrender(<Component />)
and it will set a global state inside the library - Interactions are performed using other objects as we don’t have a component instance. As an example, simulating a click requires to use a
userEvent
object:await userEvent.click(screen.getByText('Load Greeting'))
These points lead me to think Playwright would be the better choice. I’ve made a PoC and it seems to work perfectly fine even with complex components.
What are your opinions on that subject?