From e017d396dbb19c03e22b8e453bbd6c44ae68cca0 Mon Sep 17 00:00:00 2001 From: Asaf Korem Date: Mon, 6 Jan 2025 15:41:37 +0200 Subject: [PATCH] test(custom-describe): change to skip methods. --- detox/test/e2e/17.datePicker.test.js | 3 +- detox/test/e2e/17.picker.test.js | 4 +- .../e2e/copilot/01.copilot.sanity.test.js | 4 +- .../e2e/copilot/02.copilot.actions.test.js | 3 +- .../copilot/03.copilot.shape-match.test.js | 4 +- detox/test/e2e/copilot/04.webview.test.js | 4 +- detox/test/e2e/copilot/05.system.test.js | 3 +- detox/test/e2e/copilot/06.waitfor.test.js | 3 +- .../e2e/copilot/07.copilot.assertions.test.js | 3 +- .../e2e/copilot/08.copilot.location.test.js | 3 +- .../e2e/copilot/09.copilot.datepicker.test.js | 5 +-- .../e2e/copilot/10.copilot.visibility.test.js | 3 +- detox/test/e2e/setup.js | 1 + detox/test/e2e/utils/custom-describes.js | 40 ++++++++----------- 14 files changed, 30 insertions(+), 53 deletions(-) diff --git a/detox/test/e2e/17.datePicker.test.js b/detox/test/e2e/17.datePicker.test.js index 131065b053..f8bab7608a 100644 --- a/detox/test/e2e/17.datePicker.test.js +++ b/detox/test/e2e/17.datePicker.test.js @@ -1,7 +1,6 @@ -const { describeNewArchNotSupported } = require('./utils/custom-describes'); const jestExpect = require('expect').default; -describeNewArchNotSupported('DatePicker', () => { +describe.skipIfNewArch('DatePicker', () => { describe.each([ ['ios', 'compact', 0], ['ios', 'inline', 1], diff --git a/detox/test/e2e/17.picker.test.js b/detox/test/e2e/17.picker.test.js index a6be677257..a2cd329b39 100644 --- a/detox/test/e2e/17.picker.test.js +++ b/detox/test/e2e/17.picker.test.js @@ -1,6 +1,4 @@ -const { describeNewArchNotSupported } = require('./utils/custom-describes'); - -describeNewArchNotSupported(":ios: Picker", () => { +describe.skipIfNewArch(":ios: Picker", () => { beforeEach(async () => { await device.reloadReactNative(); await element(by.text("Picker")).tap(); diff --git a/detox/test/e2e/copilot/01.copilot.sanity.test.js b/detox/test/e2e/copilot/01.copilot.sanity.test.js index 56b5995a6f..9de6e4dac1 100644 --- a/detox/test/e2e/copilot/01.copilot.sanity.test.js +++ b/detox/test/e2e/copilot/01.copilot.sanity.test.js @@ -1,6 +1,4 @@ -const {describeForCopilotEnv} = require("../utils/custom-describes"); - -describeForCopilotEnv('Copilot Sanity', () => { +describe.forCopilot('Copilot Sanity', () => { beforeEach(async () => { await copilot.perform( 'Restart the React Native state', diff --git a/detox/test/e2e/copilot/02.copilot.actions.test.js b/detox/test/e2e/copilot/02.copilot.actions.test.js index bee228e8e8..f18e213505 100644 --- a/detox/test/e2e/copilot/02.copilot.actions.test.js +++ b/detox/test/e2e/copilot/02.copilot.actions.test.js @@ -1,7 +1,6 @@ -const {describeForCopilotEnv} = require("../utils/custom-describes"); const jestExpect = require('expect').default; -describeForCopilotEnv('Copilot Actions', () => { +describe.forCopilot('Copilot Actions', () => { beforeEach(async () => { await copilot.perform( 'Restart the React Native environment', diff --git a/detox/test/e2e/copilot/03.copilot.shape-match.test.js b/detox/test/e2e/copilot/03.copilot.shape-match.test.js index a9aab84752..50e3c3dad1 100644 --- a/detox/test/e2e/copilot/03.copilot.shape-match.test.js +++ b/detox/test/e2e/copilot/03.copilot.shape-match.test.js @@ -1,6 +1,4 @@ -const {describeForCopilotEnv} = require("../utils/custom-describes"); - -describeForCopilotEnv('Shape Match Game Screen', () => { +describe.forCopilot('Shape Match Game Screen', () => { beforeEach(async () => { await copilot.perform( 'Reset react native state', diff --git a/detox/test/e2e/copilot/04.webview.test.js b/detox/test/e2e/copilot/04.webview.test.js index c66c4c57ef..1e6a7346be 100644 --- a/detox/test/e2e/copilot/04.webview.test.js +++ b/detox/test/e2e/copilot/04.webview.test.js @@ -1,6 +1,4 @@ -const {describeForCopilotEnv} = require("../utils/custom-describes"); - -describeForCopilotEnv('WebView Interactions', () => { +describe.forCopilot('WebView Interactions', () => { beforeEach(async () => { await copilot.perform( 'Restart the React Native state', diff --git a/detox/test/e2e/copilot/05.system.test.js b/detox/test/e2e/copilot/05.system.test.js index ef6f5ad3df..3dbcc5a68a 100644 --- a/detox/test/e2e/copilot/05.system.test.js +++ b/detox/test/e2e/copilot/05.system.test.js @@ -1,7 +1,6 @@ -const {describeForCopilotEnv} = require("../utils/custom-describes"); const {expectToThrow} = require("../utils/custom-expects"); -describeForCopilotEnv(':ios: iOS Permission Dialogs', () => { +describe.forCopilot(':ios: iOS Permission Dialogs', () => { beforeEach(async () => { await copilot.perform( 'Remove the app and start a fresh instance', diff --git a/detox/test/e2e/copilot/06.waitfor.test.js b/detox/test/e2e/copilot/06.waitfor.test.js index 675397351a..ed9c7c0663 100644 --- a/detox/test/e2e/copilot/06.waitfor.test.js +++ b/detox/test/e2e/copilot/06.waitfor.test.js @@ -1,7 +1,6 @@ -const {describeForCopilotEnv} = require("../utils/custom-describes"); const {expectToThrow} = require("../utils/custom-expects"); -describeForCopilotEnv('WaitFor Functionality', () => { +describe.forCopilot('WaitFor Functionality', () => { beforeEach(async () => { await copilot.perform( 'Restart the React Native environment', diff --git a/detox/test/e2e/copilot/07.copilot.assertions.test.js b/detox/test/e2e/copilot/07.copilot.assertions.test.js index 1a9932031d..ef44b46007 100644 --- a/detox/test/e2e/copilot/07.copilot.assertions.test.js +++ b/detox/test/e2e/copilot/07.copilot.assertions.test.js @@ -1,7 +1,6 @@ -const { describeForCopilotEnv } = require('../utils/custom-describes'); const jestExpect = require('expect').default; -describeForCopilotEnv('Assertions', () => { +describe.forCopilot('Assertions', () => { beforeEach(async () => { await copilot.perform( 'Restart the React Native state', diff --git a/detox/test/e2e/copilot/08.copilot.location.test.js b/detox/test/e2e/copilot/08.copilot.location.test.js index ea7a1600cf..c03a1d8b67 100644 --- a/detox/test/e2e/copilot/08.copilot.location.test.js +++ b/detox/test/e2e/copilot/08.copilot.location.test.js @@ -1,10 +1,9 @@ -const { describeForCopilotEnv } = require('../utils/custom-describes'); const DUMMY_COORDINATE1_LONGITUDE = '66.5'; const DUMMY_COORDINATE1_LATITUDE = '-80.125'; const DUMMY_COORDINATE2_LONGITUDE = '-80.125'; const DUMMY_COORDINATE2_LATITUDE = '66.5'; -describeForCopilotEnv('Location', () => { +describe.forCopilot('Location', () => { beforeEach(async () => { await copilot.perform( 'Restart the React Native state', diff --git a/detox/test/e2e/copilot/09.copilot.datepicker.test.js b/detox/test/e2e/copilot/09.copilot.datepicker.test.js index d894508fa1..6d12f16d05 100644 --- a/detox/test/e2e/copilot/09.copilot.datepicker.test.js +++ b/detox/test/e2e/copilot/09.copilot.datepicker.test.js @@ -1,8 +1,7 @@ -const { describeForCopilotEnv, describeNewArchNotSupported } = require('../utils/custom-describes'); const { default: jestExpect } = require('expect'); -describeNewArchNotSupported('DatePicker', () => { - describeForCopilotEnv('Copilot', () => { +describe.skipIfNewArch('DatePicker', () => { + describe.forCopilot('Copilot', () => { beforeEach(async () => { await copilot.perform( 'Restart the React Native state', diff --git a/detox/test/e2e/copilot/10.copilot.visibility.test.js b/detox/test/e2e/copilot/10.copilot.visibility.test.js index 0d96e27bdc..3fedddf908 100644 --- a/detox/test/e2e/copilot/10.copilot.visibility.test.js +++ b/detox/test/e2e/copilot/10.copilot.visibility.test.js @@ -1,7 +1,6 @@ -const {describeForCopilotEnv} = require("../utils/custom-describes"); const { default: jestExpect } = require('expect'); -describeForCopilotEnv('Visibility', () => { +describe.forCopilot('Visibility', () => { describe('Visibility Expectation', () => { beforeEach(async () => { await copilot.perform( diff --git a/detox/test/e2e/setup.js b/detox/test/e2e/setup.js index a2bc5ea2a7..deda7dd184 100644 --- a/detox/test/e2e/setup.js +++ b/detox/test/e2e/setup.js @@ -1,4 +1,5 @@ const { device } = require('detox'); +require('./utils/custom-describes'); beforeAll(async () => { await device.selectApp('example'); diff --git a/detox/test/e2e/utils/custom-describes.js b/detox/test/e2e/utils/custom-describes.js index f66cb3f168..a42898101b 100644 --- a/detox/test/e2e/utils/custom-describes.js +++ b/detox/test/e2e/utils/custom-describes.js @@ -1,11 +1,22 @@ const axios = require('axios'); const PromptHandler = require("./PromptHandler"); -describeForCopilotEnv = (description, fn) => { +describe.skipIfCI = (title, fn) => { const isCI = process.env.CI === 'true'; - const describeOrDescribeSkipIfCI = isCI ? describe.skip : describe; + return isCI ? describe.skip(title, fn) : describe(title, fn); +}; + +describe.skipIfNewArch = (title, fn) => { + const isNewArch = process.env.RCT_NEW_ARCH_ENABLED === '1'; + if (isNewArch) { + console.warn('Skipping tests for new architecture, as there are issues related to the new architecture.'); + return describe.skip(title, fn); + } + return describe(title, fn); +}; - describeOrDescribeSkipIfCI(':ios: Copilot', () => { +describe.forCopilot = (description, fn) => { + return describe.skipIfCI(':ios: Copilot', () => { describe(description, () => { beforeAll(async () => { if (!await _checkVpnStatus()) { @@ -15,6 +26,7 @@ describeForCopilotEnv = (description, fn) => { await copilot.init(new PromptHandler()); } catch (error) { if (error.message.includes('Copilot has already been initialized')) { + // Ignore already initialized error } else { throw error; } @@ -26,7 +38,7 @@ describeForCopilotEnv = (description, fn) => { }); }; -_checkVpnStatus = async () => { +const _checkVpnStatus = async () => { try { const response = await axios.get('https://bo.wix.com/_serverless/expert-toolkit/checkVpn'); return response.data.enabled === true; @@ -35,23 +47,3 @@ _checkVpnStatus = async () => { return false; } }; - -describeNewArchNotSupported = (description, fn) => { - const isNewArch = process.env.RCT_NEW_ARCH_ENABLED === '1'; - const describeOrDescribeSkipIfNewArch = isNewArch ? describe.skip : describe; - - if (isNewArch) { - console.warn('Skipping tests for new architecture, as there are issues related to the new architecture.'); - } - - describeOrDescribeSkipIfNewArch('Legacy Arch (Paper)', () => { - describe(description, () => { - fn(); - }); - }); -} - -module.exports = { - describeForCopilotEnv, - describeNewArchNotSupported -};