From 4128df20deea9d75e71a72b07597c8d12cd1ba84 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Wed, 8 Feb 2023 08:43:54 -0800 Subject: [PATCH] Reduce flakyness on InteractionManager-test (#36092) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36092 This test is partially disabled already, causing high flakyness of the `test_windows` CI job. I'm taking a different approach at disabling it here (disabling the offending tests using a `Promise` rather than disabling at the assert level). Changelog: [Internal] [Changed] - Reduce flakyness on InteractionManager-test Reviewed By: cipolleschi Differential Revision: D43120897 fbshipit-source-id: 69edee804aaaa8b6f89ff8440561254f393efae4 --- .../__tests__/InteractionManager-test.js | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Libraries/Interaction/__tests__/InteractionManager-test.js b/Libraries/Interaction/__tests__/InteractionManager-test.js index a1a41250e5d..de32ebbf523 100644 --- a/Libraries/Interaction/__tests__/InteractionManager-test.js +++ b/Libraries/Interaction/__tests__/InteractionManager-test.js @@ -10,16 +10,15 @@ 'use strict'; -jest - .mock('../../vendor/core/ErrorUtils') - .mock('../../BatchedBridge/BatchedBridge'); +const BatchedBridge = require('../../BatchedBridge/BatchedBridge'); + +jest.mock('../../vendor/core/ErrorUtils'); +jest.mock('../../BatchedBridge/BatchedBridge'); const isWindows = process.platform === 'win32'; +const itif = condition => (condition ? it : it.skip); + function expectToBeCalledOnce(fn) { - // todo fix this test case on windows - if (isWindows) { - return; - } expect(fn.mock.calls.length).toBe(1); } @@ -159,7 +158,6 @@ describe('InteractionManager', () => { describe('promise tasks', () => { let InteractionManager; - let BatchedBridge; let sequenceId; function createSequenceTask(expectedSequenceId) { return jest.fn(() => { @@ -170,7 +168,6 @@ describe('promise tasks', () => { jest.resetModules(); jest.useFakeTimers({legacyFakeTimers: true}); InteractionManager = require('../InteractionManager'); - BatchedBridge = require('../../BatchedBridge/BatchedBridge'); sequenceId = 0; }); @@ -304,11 +301,14 @@ describe('promise tasks', () => { }, 100); }; - it('resolves async tasks recursively before other queued tasks', () => { - return new Promise(bigAsyncTest); - }); + itif(!isWindows)( + 'resolves async tasks recursively before other queued tasks', + () => { + return new Promise(bigAsyncTest); + }, + ); - it('should also work with a deadline', () => { + itif(!isWindows)('should also work with a deadline', () => { InteractionManager.setDeadline(100); BatchedBridge.getEventLoopRunningTime.mockReturnValue(200); return new Promise(bigAsyncTest);