safe-global / safe-client-gateway

Serves as a bridge for the Safe{Wallet} clients (Android, iOS, Web)
https://docs.safe.global
MIT License
27 stars 64 forks source link

Fix flaky GET Creation Transaction controller test #2107

Closed hectorgomezv closed 1 week ago

hectorgomezv commented 1 week ago

Summary

This PR fixes a flaky test affecting get-creation-transaction.transactions.controller.spec.

An example of an error in this test can be seen in the following CI run: https://github.com/safe-global/safe-client-gateway/actions/runs/11724359558/job/32658109820

The problem was the app initialization was called inside a Jest's beforeAll hook, instead of a beforeEach one. As tests run in parallel, the mocked networkService instance was shared among all the tests, and even though jest.resetAllMocks() was called on the beforeEach hook, the networkService mock behaviour was sometimes unexpected due to race conditions between tests' executions.

Changes