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

@testing-library/user-event paste() method fails when using happy-dom, works with jsdom #1167

Open
sethreidnz opened this issue Sep 18, 2023 · 1 comment
Labels
bug Something isn't working needs assessment This needs to be looked at by a team member

Comments

@sethreidnz
Copy link

Reproduction example

https://github.com/sethreidnz/testing-library-happy-dom-paste-issue

Prerequisites

  1. Clone repository
  2. Install dependencies npm install or yarn install
  3. Run the tests npm run test or yarn test
  4. See error message in console that will look like the following:
FAIL  src/App.test.tsx > App > can paste in input
TypeError: dt.setData is not a function
 ❯ getClipboardDataFromString node_modules/@testing-library/user-event/dist/esm/clipboard/paste.js:25:8
 ❯ Object.paste node_modules/@testing-library/user-event/dist/esm/clipboard/paste.js:16:70
 ❯ node_modules/@testing-library/user-event/dist/esm/setup/setup.js:84:35
 ❯ Object.asyncWrapper node_modules/@testing-library/react/dist/pure.js:73:28
 ❯ wrapAsync node_modules/@testing-library/user-event/dist/esm/setup/wrapAsync.js:7:24
 ❯ Object.method [as paste] node_modules/@testing-library/user-event/dist/esm/setup/setup.js:84:16
 ❯ src/App.test.tsx:15:16
     13|     // assert
     14|     await user.click(screen.getByRole('textbox'));
     15|     await user.paste('Hello, world!');
       |                ^
     16|   });
     17| });

Expected behavior

The paste() method should work the same as in jestdom and not produce an error.

Actual behavior

user.paste() produces a type error when using happy-dom.

User-event version

14.5.1

Environment

Testing Library framework:

JS framework: [email protected]

Test environment: [email protected]

DOM implementation: [email protected] -->

Additional context

I am not sure if this is an issue with testing library or with happy-dom so I have also raised an issue there too:

capricorn86/happy-dom#1077

@Christian24
Copy link

This is probably somewhat related to #1019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs assessment This needs to be looked at by a team member
Projects
None yet
Development

No branches or pull requests

2 participants