Skip to content

Commit

Permalink
test(custom-describe): change to skip methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
asafkorem committed Jan 6, 2025
1 parent 6902b23 commit e017d39
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 53 deletions.
3 changes: 1 addition & 2 deletions detox/test/e2e/17.datePicker.test.js
Original file line number Diff line number Diff line change
@@ -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],
Expand Down
4 changes: 1 addition & 3 deletions detox/test/e2e/17.picker.test.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
4 changes: 1 addition & 3 deletions detox/test/e2e/copilot/01.copilot.sanity.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 1 addition & 2 deletions detox/test/e2e/copilot/02.copilot.actions.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
4 changes: 1 addition & 3 deletions detox/test/e2e/copilot/03.copilot.shape-match.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
4 changes: 1 addition & 3 deletions detox/test/e2e/copilot/04.webview.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 1 addition & 2 deletions detox/test/e2e/copilot/05.system.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 1 addition & 2 deletions detox/test/e2e/copilot/06.waitfor.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 1 addition & 2 deletions detox/test/e2e/copilot/07.copilot.assertions.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 1 addition & 2 deletions detox/test/e2e/copilot/08.copilot.location.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
5 changes: 2 additions & 3 deletions detox/test/e2e/copilot/09.copilot.datepicker.test.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
3 changes: 1 addition & 2 deletions detox/test/e2e/copilot/10.copilot.visibility.test.js
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
1 change: 1 addition & 0 deletions detox/test/e2e/setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { device } = require('detox');
require('./utils/custom-describes');

beforeAll(async () => {
await device.selectApp('example');
Expand Down
40 changes: 16 additions & 24 deletions detox/test/e2e/utils/custom-describes.js
Original file line number Diff line number Diff line change
@@ -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()) {
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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
};

0 comments on commit e017d39

Please sign in to comment.