0

in my Jest test suite,

i use

jest.retryTimes(4)

because of the particular and instable architecture of the software. And this works as expected.

There are some test that must to pass at the first time so for these particular test i need to set

jest.retryTimes(1)

at the beginning of the test, restoring

jest.retryTimes(4)

at the end.

There are two problems :

  1. The problem is this configuration is global, and test are executed in parallel, so when this test start, it put 1 to jest retry for all the test running at this moment. I would like to make only this particular test fail the first time.
  2. Jest Circus ignore the update of jest.retryTimes at the beginning and at the end of the test, it keep considering 4 temptative before of raise the failure.

I read the documentation but I think I cannot obtain this result.

any suggestion?

Thanks

Andrea Bisello
  • 1,077
  • 10
  • 23
  • Probably in before/afterEach. Did you try it? – Estus Flask Dec 15 '20 at 17:18
  • thanks @EstusFlask . not working. i'm setting retryTimes(4) in a script loaded by setupFilesAfterEnv in the jest.config.js , but even setting retryTimes(1) in beforeEach, it keep trying 4 times. it look like retryTimes cannot be overwritten at runtime. – Andrea Bisello Dec 16 '20 at 10:52
  • 1
    I didn't check how the feature works yet but it seems raw. For now I'd probably go insetad with custom wrapper for `test` that does a retry like `retryTest`. – Estus Flask Dec 16 '20 at 11:10

0 Answers0