Skip to content

Commit

Permalink
chore(deps): upgrade detox-copilot.
Browse files Browse the repository at this point in the history
  • Loading branch information
LironMShemen committed Dec 15, 2024
1 parent 4d554df commit 368132f
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 41 deletions.
2 changes: 1 addition & 1 deletion detox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"caf": "^15.0.1",
"chalk": "^4.0.0",
"child-process-promise": "^2.2.0",
"detox-copilot": "^0.0.24",
"detox-copilot": "^0.0.25",
"execa": "^5.1.1",
"find-up": "^5.0.0",
"fs-extra": "^11.0.0",
Expand Down
6 changes: 5 additions & 1 deletion detox/src/DetoxWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { InvocationManager } = require('./invoke');
const symbols = require('./realms/symbols');
const AsyncEmitter = require('./utils/AsyncEmitter');
const uuid = require('./utils/uuid');

Check failure on line 11 in detox/src/DetoxWorker.js

View workflow job for this annotation

GitHub Actions / Linux

There should be at least one empty line between import groups
const { default: copilot } = require('detox-copilot');

Check failure on line 12 in detox/src/DetoxWorker.js

View workflow job for this annotation

GitHub Actions / Linux

`detox-copilot` import should occur before import of `lodash`

class DetoxWorker {
constructor(context) {
Expand Down Expand Up @@ -228,7 +229,7 @@ class DetoxWorker {

onTestStart = function* (_signal, testSummary) {
// Copilot is reset before each test to ensure a clean state
this.copilot.resetIfNeeded();
this.copilot.start();

this._validateTestSummary('beforeEach', testSummary);

Expand Down Expand Up @@ -257,6 +258,9 @@ class DetoxWorker {
pendingRequests: testSummary.timedOut,
testName: testSummary.fullName,
});

// Pass false to copilot, so temporary cache is not saved
copilot.end(testSummary.status === 'passed');
};

onRunDescribeFinish = function* (_signal, ...args) {
Expand Down
12 changes: 5 additions & 7 deletions detox/src/copilot/DetoxCopilot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const copilot = require('detox-copilot').default;

Check failure on line 1 in detox/src/copilot/DetoxCopilot.js

View workflow job for this annotation

GitHub Actions / Linux

There should be at least one empty line between import groups

const detoxCopilotFrameworkDriver = require('./detoxCopilotFrameworkDriver');

class DetoxCopilot {
Expand All @@ -16,13 +15,12 @@ class DetoxCopilot {
this.isInitialized = true;
}

resetIfNeeded() {
if (!this.isInitialized) {
// Copilot is not initialized, nothing to reset
return;
}
start() {
copilot.start();
}

copilot.reset();
end(saveToCache) {
copilot.end(saveToCache);
}

perform(...steps) {
Expand Down
9 changes: 4 additions & 5 deletions detox/test/e2e/copilot/01.copilot.sanity.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const {describeForCopilotEnv} = require("../utils/custom-describes");

describeForCopilotEnv('Copilot Sanity', () => {
beforeAll(async () => {
await copilot.perform('Launch the app');
});

beforeEach(async () => {
await copilot.perform('Reset react native state', 'Navigate to sanity');
await copilot.perform(
'Restart the React Native state',
'Navigate to the Sanity screen'
);
});

it('should have welcome screen', async () => {
Expand Down
4 changes: 0 additions & 4 deletions detox/test/e2e/copilot/02.copilot.actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const {describeForCopilotEnv} = require("../utils/custom-describes");
const jestExpect = require('expect').default;

describeForCopilotEnv('Copilot Actions', () => {
beforeAll(async () => {
await copilot.perform('Start the application');
});

beforeEach(async () => {
await copilot.perform(
'Restart the React Native environment',
Expand Down
8 changes: 5 additions & 3 deletions detox/test/e2e/copilot/03.copilot.shape-match.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const {describeForCopilotEnv} = require("../utils/custom-describes");

describeForCopilotEnv('Shape Match Game Screen', () => {
beforeAll(async () => {
await copilot.perform('Launch the app');
beforeEach(async () => {
await copilot.perform(
'Reset react native state',
'Enter the "Shape Matching" game screen'
);
});

it('should play the Shape Matching game', async () => {
await copilot.perform(
'Enter the "Shape Matching" game screen',
'Game has started with score 0',

'Drag the blue square into the middle of its hole',
Expand Down
4 changes: 0 additions & 4 deletions detox/test/e2e/copilot/04.webview.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const {describeForCopilotEnv} = require("../utils/custom-describes");

describeForCopilotEnv('WebView Interactions', () => {
beforeAll(async () => {
await copilot.perform('Start the app');
});

beforeEach(async () => {
await copilot.perform(
'Restart the React Native state',
Expand Down
4 changes: 0 additions & 4 deletions detox/test/e2e/copilot/06.waitfor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const {describeForCopilotEnv} = require("../utils/custom-describes");
const {expectToThrow} = require("../utils/custom-expects");

describeForCopilotEnv('WaitFor Functionality', () => {
beforeAll(async () => {
await copilot.perform('Launch the application');
});

beforeEach(async () => {
await copilot.perform(
'Restart the React Native environment',
Expand Down
4 changes: 0 additions & 4 deletions detox/test/e2e/copilot/07.copilot.assertions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const { describeForCopilotEnv } = require('../utils/custom-describes');
const jestExpect = require('expect').default;

describeForCopilotEnv('Assertions', () => {
beforeAll(async () => {
await copilot.perform('Start the app');
});

beforeEach(async () => {
await copilot.perform(
'Restart the React Native state',
Expand Down
4 changes: 0 additions & 4 deletions detox/test/e2e/copilot/09.copilot.datepicker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const { describeForCopilotEnv } = require('../utils/custom-describes');
const { default: jestExpect } = require('expect');

describeForCopilotEnv('DatePicker', () => {
beforeAll(async () => {
await copilot.perform('Start the app');
});

beforeEach(async () => {
await copilot.perform(
'Restart the React Native state',
Expand Down
4 changes: 0 additions & 4 deletions detox/test/e2e/copilot/10.copilot.visibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const {describeForCopilotEnv} = require("../utils/custom-describes");
const { default: jestExpect } = require('expect');

describeForCopilotEnv('Visibility', () => {
beforeAll(async () => {
await copilot.perform('Start the app');
});

describe('Visibility Expectation', () => {
beforeEach(async () => {
await copilot.perform(
Expand Down

0 comments on commit 368132f

Please sign in to comment.