diff --git a/tests/e2e/nativeCommands/NativeCommandsAction.js b/tests/e2e/nativeCommands/NativeCommandsAction.ts similarity index 62% rename from tests/e2e/nativeCommands/NativeCommandsAction.js rename to tests/e2e/nativeCommands/NativeCommandsAction.ts index 24ceefb5acb7..17187ca66f1c 100644 --- a/tests/e2e/nativeCommands/NativeCommandsAction.js +++ b/tests/e2e/nativeCommands/NativeCommandsAction.ts @@ -1,17 +1,19 @@ +import type {NativeCommand} from '@libs/E2E/client'; + const NativeCommandsAction = { scroll: 'scroll', type: 'type', backspace: 'backspace', -}; +} as const; -const makeTypeTextCommand = (text) => ({ +const makeTypeTextCommand = (text: string): NativeCommand => ({ actionName: NativeCommandsAction.type, payload: { text, }, }); -const makeBackspaceCommand = () => ({ +const makeBackspaceCommand = (): NativeCommand => ({ actionName: NativeCommandsAction.backspace, }); diff --git a/tests/e2e/utils/sleep.js b/tests/e2e/utils/sleep.ts similarity index 54% rename from tests/e2e/utils/sleep.js rename to tests/e2e/utils/sleep.ts index 6d37ca3cd510..c3f7142a898f 100644 --- a/tests/e2e/utils/sleep.js +++ b/tests/e2e/utils/sleep.ts @@ -1,5 +1,7 @@ -export default function sleep(ms) { +function sleep(ms: number): Promise { return new Promise((resolve) => { setTimeout(resolve, ms); }); } + +export default sleep; diff --git a/tests/utils/waitForBatchedUpdates.js b/tests/utils/waitForBatchedUpdates.ts similarity index 94% rename from tests/utils/waitForBatchedUpdates.js rename to tests/utils/waitForBatchedUpdates.ts index c9d7a99fa1fb..8455371093d8 100644 --- a/tests/utils/waitForBatchedUpdates.js +++ b/tests/utils/waitForBatchedUpdates.ts @@ -10,10 +10,8 @@ import getIsUsingFakeTimers from './getIsUsingFakeTimers'; * than to do * ❌ Onyx.merge(...) * waitForBatchedUpdates().then(...) - * - * @returns {Promise} */ -export default () => +const waitForBatchedUpdates = (): Promise => new Promise((outerResolve) => { // We first need to exhaust the microtask queue, before we schedule the next task in the macrotask queue (setTimeout). // This is because we need to wait for all async onyx operations to finish, as they might schedule other macrotasks, @@ -38,3 +36,5 @@ export default () => setTimeout(outerResolve, 0); }); }); + +export default waitForBatchedUpdates; diff --git a/tests/utils/waitForNetworkPromises.js b/tests/utils/waitForNetworkPromises.ts similarity index 74% rename from tests/utils/waitForNetworkPromises.js rename to tests/utils/waitForNetworkPromises.ts index a60061d597e3..8c35514b870e 100644 --- a/tests/utils/waitForNetworkPromises.js +++ b/tests/utils/waitForNetworkPromises.ts @@ -8,7 +8,7 @@ import waitForBatchedUpdates from './waitForBatchedUpdates'; * than to do * ❌ Onyx.merge(...) * waitForBatchedUpdates().then(...) - * - * @returns {Promise} */ -export default () => waitForBatchedUpdates().then(waitForBatchedUpdates); +const waitForNetworkPromises = (): Promise => waitForBatchedUpdates().then(waitForBatchedUpdates); + +export default waitForNetworkPromises; diff --git a/tests/utils/wrapOnyxWithWaitForBatchedUpdates.js b/tests/utils/wrapOnyxWithWaitForBatchedUpdates.ts similarity index 84% rename from tests/utils/wrapOnyxWithWaitForBatchedUpdates.js rename to tests/utils/wrapOnyxWithWaitForBatchedUpdates.ts index e5b6e6bfdfcf..862f3281b2b8 100644 --- a/tests/utils/wrapOnyxWithWaitForBatchedUpdates.js +++ b/tests/utils/wrapOnyxWithWaitForBatchedUpdates.ts @@ -1,3 +1,4 @@ +import type Onyx from 'react-native-onyx'; import waitForBatchedUpdates from './waitForBatchedUpdates'; /** @@ -7,10 +8,8 @@ import waitForBatchedUpdates from './waitForBatchedUpdates'; * are rendered with the onyx data. * This is a convinience function, which wraps the onyxInstance's * functions, to for the promises to resolve. - * - * @param {Object} onyxInstance */ -export default function wrapOnyxWithWaitForBatchedUpdates(onyxInstance) { +function wrapOnyxWithWaitForBatchedUpdates(onyxInstance: typeof Onyx) { const multiSetImpl = onyxInstance.multiSet; // eslint-disable-next-line no-param-reassign onyxInstance.multiSet = (...args) => multiSetImpl(...args).then((result) => waitForBatchedUpdates().then(() => result)); @@ -18,3 +17,5 @@ export default function wrapOnyxWithWaitForBatchedUpdates(onyxInstance) { // eslint-disable-next-line no-param-reassign onyxInstance.merge = (...args) => mergeImpl(...args).then((result) => waitForBatchedUpdates().then(() => result)); } + +export default wrapOnyxWithWaitForBatchedUpdates;