testing-library / testing-library/user-event

userEvent.paste possibly casts string to a number

Open
#1,053 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Reproduction example

https://codesandbox.io/s/happy-architecture-1crzb7?file=/src/App.test.js

Prerequisites
  1. Go to Tests tab and run the test
  2. Notice that the test fails due to mismatched paste value
  3. If you check console log of App, the raw e.target.value equals to 0.8 (instead of .80)
Expected behavior

userEvent.paste should return .80.

Actual behavior

userEvent.paste returns 0.8 (was somehow cast to a number?).

User-event version

14.4.3

Environment

N/A. Can be reproduced in codesandbox.

Additional context

This used to work in v13+. Please see repro below.
https://codesandbox.io/s/hungry-wildflower-e5o25n?file=/src/App.test.js

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 the reproduction in App.test.js and the userEvent.paste entry point, comparing the v14.4.3 behavior with the v13 reproduction. Add a regression test showing that pasted .80 remains .80, then run the relevant user-event tests and confirm the raw target value is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.