Answer the question
In order to leave comments, you need to log in
How to test component attribute if it is a function?
Good afternoon! Please tell me how you can test with jest the changePage attribute which is a function.
<Component
changePage = {(page) => callFuntion(page)}
/>
Answer the question
In order to leave comments, you need to log in
It's not entirely clear what exactly you want to test, but most likely you need this:
https://jestjs.io/docs/en/mock-functions
"component attribute" is not tested. Any logic is being tested.
If you want to test the function itself, then separate it into a separate function and write a test for it
like this
function changePage(page) {
callFunction(page)
}
<Component
changePage = {changePage}
/>
///где-то в тестах пишете тест для changePage.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question