*Question:* How to stub an import/function after a...
# component-testing
a
Question: How to stub an import/function after an assertion? Scenario: - A
button
with
customhook
called. Based on the response of customhook (false/true), the button text will be changing. - During initial render, customHook returns
false
and the text is
xxxx
. - After
clicking
the button, the customHook returns
true
and the text will be changed to
yyyy
Solution tried: 1 - stubbed the custom hook to return false. 2- mount the button (during which a customhook will be called and return false) 3 - assert the button text to be
xxxx
4 - stubbed the custom hook to return true. 5 - cy.get("button").click(); 6 - assert the new button text to be
yyyy
Outputs: Error: An import cannot be wrapped 2 times. Can any one help me on this?