R
R
Rqik2021-02-17 15:10:30
JavaScript
Rqik, 2021-02-17 15:10:30

How in jest to test a method in a class that is called by condition?

Example there is a method in a class

sliderInit() {
    if (this.state.showInterval) {
      this.intervalExpose()
    }}

how can i test intervalExpose if it is called by condition

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Ommonik, 2021-02-17
@Ommonick

Initialize class object with condition included?

A
alex4answ, 2021-02-17
@alex4answ

test it separately.
If you are sliderInittesting then spy/mock the intervalExpose and seemock.calls

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question