Superset uses Jest and React Testing Library (RTL) to write unit and integration tests. In the past we used Enzyme, but now that we're currently converting all of our class components to functional components, Enzyme cannot support our testing needs. Since RTL is better for testing functional components, we're converting all of our test files to RTL. This can be quite a learning curve - I've gone through a lot of the process so I'd like to share what I've learned so far.

First and foremost: We have a Testing Guidelines and Best Practices document that outlines all the code styles we adhere to in our tests. Please use this document as a reference when writing your tests.

The main thing you want to keep in mind is the different approaches each testing library uses in testing:

The test environment in Superset is getting healthier and easier to work with by the day, and I hope this will inspire you to help contribute to the cause!

To wrap this up, I would like to leave you with some good RTL/testing resources:

const button = screen.getByRole('button');
screen.debug(button);
screen.logTestingPlaygroundURL(button);

Originally posted here.

Lead image source.