Open sethreidnz opened 1 year ago
https://github.com/sethreidnz/testing-library-happy-dom-paste-issue
npm install
yarn install
npm run test
yarn test
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| });
The paste() method should work the same as in jestdom and not produce an error.
user.paste() produces a type error when using happy-dom.
14.5.1
Testing Library framework:
JS framework: react@18.2.15
react@18.2.15
Test environment: vitest@20.34.4
vitest@20.34.4
DOM implementation: happy-dom@12.1.2 -->
happy-dom@12.1.2
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:
https://github.com/capricorn86/happy-dom/issues/1077
This is probably somewhat related to #1019
Reproduction example
https://github.com/sethreidnz/testing-library-happy-dom-paste-issue
Prerequisites
npm install
oryarn install
npm run test
oryarn test
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:
react@18.2.15
Test environment:
vitest@20.34.4
DOM implementation:
happy-dom@12.1.2
-->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:
https://github.com/capricorn86/happy-dom/issues/1077