testing-library / testing-library/user-event

Rethink testing strategy

Open
#1,019 22 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
2.3k
Forks
258
PR merge metrics
No merged PRs in 30d

Description

Problem description
  1. We run linting and tests on multiple node versions that we support according to
    https://github.com/testing-library/user-event/blob/ea5023141740123aede05561913cb2ec14952e2b/package.json#L13-L14
    This has no merits.
    Our source code has no dependency on any NodeJS API, so that the result for the source itself will always be the same.
    The tested code is not the distributed code, so that if the different NodeJS versions yield different results, it only flags problems with our testing environment, but don't indicate anything about the build we would distribute from that commit.

  2. We don't test our build. Misconfigurations or bugs in our build tools result in broken builds being published and any potential fix is verified only by manually testing the build.

  3. We only test on Jsdom. We try to be platform agnostic, but out automation doesn't help us to develop software that works as intended in different environments, and the differences between Jsdom and e.g. Chrome are too numerous and wide for relying on manual testing only.

Suggested solution
  • Remove source tests on older node versions.
  • Refactor the tests so that they don't rely on Jest and could be run in different environments.
  • Run the tests in a headless browser during CI.
  • Split up our tests in
    a) those that rely on mocks or test internals and
    b) those that only interact with the DOM and can be observed using only the main export.
  • Add at least a smoke test on different node versions using the build.
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with package.json at the linked Node.js version configuration and inspect the existing CI, build, and test setup. Separate tests that rely on mocks or internals from DOM-only tests, then add build smoke coverage across Node.js versions and verify the DOM-focused tests can run against the intended environments.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
build-system, ci-cd, testing-qa
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.