Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve frontend unit-testing experience #26960

Closed
11 of 12 tasks
kulyk opened this issue Dec 5, 2022 · 2 comments
Closed
11 of 12 tasks

Improve frontend unit-testing experience #26960

kulyk opened this issue Dec 5, 2022 · 2 comments
Assignees
Labels
.Epic Feature Implementation or Project Type:Tech Debt or Refactoring

Comments

@kulyk
Copy link
Member

kulyk commented Dec 5, 2022

Problem

We heavily rely on Cypress E2E tests in our quality process, probably way more than we actually should. One of the reasons people tend to write more E2E tests instead of more lightweight jest tests is because the toolchain and overall process can be confusing:

  • it's hard to mock/assert HTTP requests/responses with xhr-mock, more details in Migrate away from XMLHttpRequest #17906
  • we don't have a consistent way of organizing tests (e.g. a lot of tests still live in frontend/test/metabase, and we prefer to keep tests close to the source code nowadays)
  • we came up with a handful of test helpers, but they're sometimes hard to find as they live in different places
  • jest console is polluted with errors and warnings on most of the test runs
  • there's a lot of manual work going on to prepare the test environment (e.g. setup of the expected instance settings)

Suggested Solution

We want to get to the point when every FE engineer on the team can put together a simple test using shared helpers and quickly be able to:

  • mock/assert the server behavior to test out components and parts of the app talking to the server
  • test their code against a variety of incoming data, especially questions (saved vs. ad-hoc, question vs model, native vs structured, etc.)
  • test OSS vs. paid plan behavior

Tasks

⏳ Total ETA for this is around 1-2 weeks

Milestone 1

Milestone 2

@kulyk kulyk added Type:Tech Debt or Refactoring .Epic Feature Implementation or Project labels Dec 5, 2022
@iethree
Copy link
Contributor

iethree commented Dec 6, 2022

I don't know if this is a blocker for us for MSW, but it does not support concurrent runs in jest
mswjs/msw#474

This can be a problem when you have tests running concurrently that are trying to mock different API response payloads - you can't predict which one you will get, because it overwrites response handlers

I think Nock is not susceptible to this issue, but haven't used it, so can't comment on other possible pitfalls.

@nemanjaglumac
Copy link
Member

Amazing job everyone involved in this massive task! 👏 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Epic Feature Implementation or Project Type:Tech Debt or Refactoring
Projects
None yet
Development

No branches or pull requests

3 participants