Skip to content

feat: device.resetAppState([...bundleIds])#4819

Merged
noomorph merged 3 commits intomasterfrom
feat/reset-app-state
Sep 24, 2025
Merged

feat: device.resetAppState([...bundleIds])#4819
noomorph merged 3 commits intomasterfrom
feat/reset-app-state

Conversation

@noomorph
Copy link
Copy Markdown
Collaborator

@noomorph noomorph commented Aug 20, 2025

Description

In this pull request, I have implemented a new device.resetAppState([...bundleIds]) method that provides a more efficient way to reset app state compared to the traditional uninstall/reinstall cycle. This feature addresses performance concerns when running tests that require clean app state between test runs.

  • Android: Uses pm clear command to clear app data without uninstalling the app
  • iOS: Implements a backup/restore mechanism which works without need to have app binaries available

Usage Examples:

// Reset current app state
await device.resetAppState();

// Reset specific app state
await device.resetAppState('com.example.app');

// Reset multiple apps
await device.resetAppState('com.app1', 'com.app2');

For features/enhancements:

  • I have added/updated the relevant references in the documentation files.

For API changes:

  • I have made the necessary changes in the types index file.

Copy link
Copy Markdown
Contributor

@d4vidi d4vidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary:

  1. I don't think the global optimizeReinstall flag is a good approach. More on that - inside.
  2. Generated unit test code quality is poor. Preferably that can be fixed using good-enough cursor rules, but otherwise please let's try to avoid allowing AI with leaving us like that.
  3. Sporadic suggestions

@noomorph noomorph force-pushed the feat/reset-app-state branch from 07a6b7a to 6265a68 Compare September 24, 2025 12:30
@noomorph noomorph merged commit 431c41f into master Sep 24, 2025
6 of 7 checks passed
@noomorph noomorph deleted the feat/reset-app-state branch September 24, 2025 13:02
@erdemkiiliic
Copy link
Copy Markdown

@noomorph Hey man, First of all, great work. While checking, I noticed something:

await device.launchApp({
  resetAppState: true,
  newInstance: true,
  permissions: {
    userTracking: 'YES',
    notifications: 'YES',
    camera: 'YES',
    location: 'always',
    microphone: 'YES',
    contacts: 'YES',
  },
  launchArgs,
});

with this usage, it resets the behavior as expected, but I see that the permissions cannot be re-granted. Similarly, when using { delete: true }, I see that the app starts with the permissions granted. I also saw this note in the documentation:
‘Similar to {@link Detox.DeviceLaunchAppConfig.delete | { delete: true }}, but instead of uninstalling and installing the app,’

However, I wanted to point out that it doesn’t seem to work in the same way. Wouldn’t it be better if the behavior were made similar to the delete option? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants