Reputation: 7551
I'm having issues moving react testing lib tests from create react app to vite:
src/Pages/WelcomePage/views/SelectUser/index.test.jsx [ src/Pages/WelcomePage/views/SelectUser/index.test.jsx ]
Error: Cannot find module 'react-dom/client'
Require stack:
- /Users/nikos/WebstormPro.../node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@testing-library/react/dist/pure.js
❯ Object.<anonymous> node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@testing-library/react/dist/pure.js:35:46
Current libs in white
edit -------------- upgrading to
"react": "^18.1.0",
"react-dom": "^18.1.0",
fixed the above but now I get:
❯ resetClipboardStubOnView node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@testing-library/user-event/dist/index.mjs:320:30
318| }
319| function resetClipboardStubOnView(window) {
320| if (isClipboardStub(window.navigator.clipboard)) {
| ^
Upvotes: 2
Views: 1080
Reputation: 7551
Missing the following in the vite config
test: {
globals: true,
environment: "happy-dom", // or 'jsdom', 'node'
},
If you get error Error: Cannot find module 'react-dom/client'
Upgrade to React 18 and tell your clients you are dumping ie11.
Upvotes: 1