Skip to content

Commit

Permalink
test(e2e): refactor skip mechanism (#4559)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored Aug 21, 2024
1 parent fc78018 commit 1036718
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 78 deletions.
3 changes: 1 addition & 2 deletions detox/test/e2e/03.actions.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const driver = require('./drivers/actions-driver').actionsScreenDriver;
const custom = require('./utils/custom-it');

describe('Actions', () => {
beforeAll(async () => {
Expand Down Expand Up @@ -227,7 +226,7 @@ describe('Actions', () => {
await expect(element(by.id('UniqueId007'))).toBeVisible();
});

custom.it.skipFromRNVersion(71)('should adjust legacy slider and assert its value', async () => {
it('@rn71 should adjust legacy slider and assert its value', async () => {
const reactSliderId = 'legacySliderWithASimpleID';
await expect(element(by.id(reactSliderId))).toHaveSliderPosition(0.25);
await element(by.id(reactSliderId)).adjustSliderToPosition(0.75);
Expand Down
3 changes: 1 addition & 2 deletions detox/test/e2e/33.attributes.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { device, element, by } = require('detox');
const expect = require('expect').default;
const custom = require('./utils/custom-it');

describe('Attributes', () => {
/** @type {Detox.IndexableNativeElement} */
Expand Down Expand Up @@ -157,7 +156,7 @@ describe('Attributes', () => {
});
});

custom.describe.skipFromRNVersion(71)('of a legacy slider', () => {
describe('of a legacy slider (@rn71)', () => {
beforeAll(() => useMatcher(by.id('legacySliderId')));

it(':ios: should have a string percent .value, and .normalizedSliderPosition', () => {
Expand Down
5 changes: 2 additions & 3 deletions detox/test/e2e/35.overlay.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { expectToThrow } = require('./utils/custom-expects');
const custom = require('./utils/custom-it');

describe(':ios: Overlay', () => {
let showAlertButton;
Expand Down Expand Up @@ -55,11 +54,11 @@ describe(':ios: Overlay', () => {
await dismissAlertButton.tap();
});

custom.it.withFailureIf.iOSWithRNLessThan67('should be able to tap on elements', async () => {
it('should be able to tap on elements', async () => {
await showOverlayWindowButton.tap();
});

custom.it.withFailureIf.iOSWithRNLessThan67('should be able to scroll elements', async () => {
it('should be able to scroll elements', async () => {
await verticalScrollView.scrollTo('bottom');
await expect(showOverlayWindowButton).not.toBeVisible();
});
Expand Down
1 change: 1 addition & 0 deletions detox/test/e2e/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = async () => {
'jest-metadata/environment-listener',
'jest-allure2-reporter/environment-listener',
require.resolve('detox-allure2-adapter'),
require.resolve('./utils/rnSkipper'),
]
},
'testRunner': './test/node_modules/jest-circus/runner',
Expand Down
71 changes: 0 additions & 71 deletions detox/test/e2e/utils/custom-it.js

This file was deleted.

21 changes: 21 additions & 0 deletions detox/test/e2e/utils/rnSkipper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const rn = require('../../../src/utils/rn-consts/rn-consts').rnVersion.minor;

/** @type {import('jest-environment-emit').EnvironmentListenerFn} */
const listener = ({ testEvents }) => {
testEvents
.on('start_describe_definition', ({ event: { blockName }, state: { currentDescribeBlock }}) => {
const match = blockName.match(/@rn(\d+)/i);
if (match && match[1] != rn) {
currentDescribeBlock.mode = 'skip';
}
})
.on('add_test', ({ event: { testName }, state: { currentDescribeBlock }}) => {
const match = testName.match(/@rn(\d+)/i);
if (match && match[1] != rn) {
const n = currentDescribeBlock.children.length;
currentDescribeBlock.children[n - 1].mode = 'skip';
}
});
};

module.exports = listener;

0 comments on commit 1036718

Please sign in to comment.