Replies: 3 comments 3 replies
-
Are you starting the service before passing it to component B in your test? Maybe you can post a code snippet of your test? |
Beta Was this translation helpful? Give feedback.
-
✏️ Please create a CodeSandbox (React template) reproduction of this. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I solved it by starting
Then, why I have to start |
Beta Was this translation helpful? Give feedback.
-
Situation
service
variable from component A to component B.service
to be tested using Jest and React testing library.service
variable in test file.From this problem, I thought another way.
service
, but it needs initial value for initial state.null
as initial value forservice
, but when I useuseService
hook, it couldn't benull
.service
when this variable is notnull
, but hook can only be used in top-level as you know.Consequently, I have to start service without any hooks , like just function call. How can I solve it? Or is there other way?
Beta Was this translation helpful? Give feedback.
All reactions