Skip to content

Commit

Permalink
feat: undeprecate device.relaunchApp() (#3362)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed May 13, 2022
1 parent 5af13fe commit b814ba6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
9 changes: 9 additions & 0 deletions detox/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,15 @@ declare global {
*/
launchApp(config?: DeviceLaunchAppConfig): Promise<void>;

/**
* Relaunch the app. Convenience method that calls {@link Device#launchApp}
* with { newInstance: true } override.
*
* @param config
* @see Device#launchApp
*/
relaunchApp(config?: Omit<DeviceLaunchAppConfig, 'newInstance'>): Promise<void>;

/**
* Access the user-defined launch-arguments predefined through static scopes such as the Detox configuration file and
* command-line arguments. This access allows - through dedicated methods, for both value-querying and
Expand Down
3 changes: 0 additions & 3 deletions detox/src/devices/runtime/RuntimeDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ class RuntimeDevice {
return traceCall('launchApp', () => this._doLaunchApp(params, bundleId));
}

/**
* @deprecated
*/
async relaunchApp(params = {}, bundleId) {
if (params.newInstance === undefined) {
params['newInstance'] = true;
Expand Down
39 changes: 39 additions & 0 deletions detox/test/types/detox-module-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,45 @@ import { by, device, element, expect, waitFor } from 'detox';
describe('Test', () => {
beforeAll(async () => {
await device.reloadReactNative();
await device.launchApp({
newInstance: false,
permissions: {
location: 'always',
notifications: 'YES',
calendar: 'NO',
camera: 'YES',
contacts: 'NO',
health: 'YES',
homekit: 'NO',
medialibrary: 'YES',
microphone: 'NO',
motion: 'YES',
photos: 'NO',
reminders: 'YES',
siri: 'NO',
speech: 'YES',
faceid: 'NO',
userTracking: 'YES',
},
url: 'detoxtesturlscheme://such-string',
userNotification: {},
userActivity: {},
delete: false,
launchArgs: {
someArg: 42,
},
languageAndLocale: {
language: 'en',
locale: 'en-CA',
},
});

await device.relaunchApp();
await device.relaunchApp({
launchArgs: {
someArg: 42,
},
});
});

afterAll(async () => {
Expand Down
4 changes: 2 additions & 2 deletions docs/APIRef.DeviceObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ Launches the app with a URL blacklist to disable network synchronization on cert
await device.launchApp({
newInstance: true,
launchArgs: { detoxURLBlacklistRegex: ' \\("http://192.168.1.253:19001/onchange","https://e.crashlytics.com/spi/v2/events"\\)' },
});
});
```
#### `device.relaunchApp(params)`
**Deprecated:** Use `device.launchApp(params)` instead. The method calls `launchApp({newInstance: true})` for backwards compatibility.
The method calls `launchApp({newInstance: true})` as a convenience method.
#### `device.terminateApp()`
Expand Down

0 comments on commit b814ba6

Please sign in to comment.