Skip to content

clearState ​

Clear app data, cache, and preferences to reset to a fresh install state.

Clears all data for a specified mobile application.

Usage examples ​

To clear the state of the current app, use add the clearState command alone.

yaml
- clearState

If you want to clear the state of a specific app by its ID, add the app ID:

yaml
- clearState: app.id

You can also add a label when invoking clearState to improve the readability of the report.

yaml
- clearState:
    appId: app.id
    label: Reset ExampleApp

Platform-specific behavior ​

The command's behavior differs based on the mobile operating system.

Android ​

On Android, the clearState command is equivalent to running:

adb shell pm clear {package name}

It removes all app-related data from the device, such as shared preferences, databases, and accounts.

iOS ​

On iOS, the clearState command causes the runner to reinstall the entire app (on a real iPhone, from the app file you provide for the run), resulting in a completely fresh install and removing all existing data folders.

As described in Stack Overflow discussion, it's also possible to xcrun simctl to perform the same action.