I am new to unit testing and planning to write unit test cases but not E-2-E for the below mentioned scenario and playgrounnd link for scenario is at the bottom.
Scenario:-
I have a @State
variable called "ifSuccessResponse"
with initial value set as false
.
When @State
variable "ifSuccessResponse"
is true
, green-div
loads.
When @State
variable "ifSuccessResponse"
is false
, red-div
loads.
- How to mock initial state to have
@State
variableifSuccessResponse
to have value set astrue
and then load the newSpecPage so that I can testgreen-div
is loaded.
- Is it possible to update the
@State
variableifSuccessResponse
after loading the page in Moc Doc usingnewSpecPage
. Curious to know whether we can do this like how we can do inenzyme
library usingsetState method
.
Playground-link
:
https://webcomponents.dev/edit/Cbr1NS2QTrvC5scsmFZQ/src/index.stories.tsx