2

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

enter image description here

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)) {
       |                              ^

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.