Skip to content

Commit 0dfcd2d

Browse files
committed
fix: copilot legacy access
1 parent 3495b8c commit 0dfcd2d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Diff for: detox/src/DetoxWorker.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class DetoxWorker {
6363
this.system = null;
6464
/** @type {Detox.PilotFacade} */
6565
this.pilot = null;
66+
/** @type {Detox.PilotFacade} */
67+
this.copilot = null;
6668

6769
this._deviceCookie = null;
6870

@@ -110,6 +112,13 @@ class DetoxWorker {
110112
}
111113
};
112114
this.pilot = new DetoxPilot();
115+
Object.defineProperty(this, 'copilot', {
116+
get: () => {
117+
console.warn('Warning: "copilot" is deprecated. Please use "pilot" instead.');
118+
return this.pilot;
119+
},
120+
configurable: true,
121+
});
113122

114123
yield this._client.connect();
115124

@@ -169,10 +178,7 @@ class DetoxWorker {
169178
this._injectedGlobalProperties = Object.keys(injectedGlobals);
170179
Object.assign(DetoxWorker.global, injectedGlobals);
171180
Object.defineProperty(DetoxWorker.global, 'copilot', {
172-
get: () => {
173-
console.warn('Warning: "copilot" is deprecated. Please use "pilot" instead.');
174-
return this.pilot;
175-
},
181+
get: () => this.copilot,
176182
configurable: true,
177183
});
178184
}

Diff for: detox/test/e2e/pilot/01.pilot.sanity.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { copilot } from 'detox';
2+
13
describe.forPilot('Pilot Sanity', () => {
24
beforeEach(async () => {
35
await pilot.perform(
@@ -19,6 +21,10 @@ describe.forPilot('Pilot Sanity', () => {
1921
});
2022

2123
it('should show world screen after tap with Copilot (deprecated API)', async () => {
24+
await global.copilot.autopilot('tap on the Say World button in the sanity screen and expect to see "World!!!" text displayed');
25+
});
26+
27+
it('should access copilot via destructuring', async () => {
2228
await copilot.autopilot('tap on the Say World button in the sanity screen and expect to see "World!!!" text displayed');
2329
});
2430
});

0 commit comments

Comments
 (0)