testing-library / testing-library/user-event

Use consistent test style across codebase

Open
#560 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In https://github.com/testing-library/user-event/pull/558 discussions, we've noticed that the test files across the codebase have a mix of declarative and imperative style.

What happened: When contributing for the first time, I didn't know what style to follow while coding the tests since it's mixed across the codebase and there's tool/docs mention to enforce it

The following code is from __tests__/paste.js

// declarative
test('should paste text in textarea', () => { ... }

// imperative
test('does not paste when readOnly', () => { ... }

Reproduction repository: Go through the tests file of the codebase and see a mixture of declarative and imperative styles.

Problem description: Contributors should know whether style to choose, the current situations may cause a lot of confusion and PR discussions

Suggested solution: Discuss in this issue the following topics:

  1. What would be the best test style for this codebase: Declarative or Imperative?
  2. How to enforce a test style?

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

Begin with tests/paste.js and the discussion in pull request #558, then review surrounding test files to compare the two styles. Done means the project has agreed on one style and documented or enforced it for contributors; the issue does not name a specific enforcement file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
developer-experience, testing
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.