paralleldrive / riteway

Simple, readable, helpful unit tests.
MIT License
1.15k stars 35 forks source link

error when using render react component functionality with latest react version #329

Closed tgrecojs closed 2 years ago

tgrecojs commented 2 years ago

Recently came across an issue using riteway from the context of a next.js app. Below is a stack-trace showing the specifics.

npm run test

> nextjs-app@1.0.0 test
> riteway -r @babel/register 'source/index.test.js' | tap-nirvana

 renderComponent
Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
    ✖  TypeError: Cannot read properties of null (reading 'useRef')
    ----------------------------------------------------------------
        operator: deepEqual
        diff:
        source: at _callee$ (/nextjs-app/source/features/LandingPage/component.test.js:6:13)

passed: 0,  failed: 1  of 1 tests  (558ms)

I wasn't making use of hooks yet, so I could rule that out and move on to checking the versions my project had installed. This led me seeing that riteway had a react-dom version that conflicted with my project.

npm ls react-dom
nextjs-app@1.0.0 /nextjs-app
├─┬ next@12.1.6
│ └── react-dom@18.1.0 deduped
├── react-dom@18.1.0
└─┬ riteway@6.3.1
  └── react-dom@17.0.2
tgrecojs commented 2 years ago

below is a sample repo showing riteway behaving correctly when installed alongside next@11 react@17 react-dom@17

https://github.com/tgrecojs/riteway-react-error-repro

ericelliott commented 2 years ago

Should be fixed in riteway@7.0.0 - please re-open if you still have trouble.