Files
safe-wallet/apps/mobile/docs/e2e-tests-guidelines.md
zeekay 7200114387 Merge upstream/dev (52 commits) + sweep yarn → pnpm
Upstream merge brings 52 commits from safe-global/safe-wallet-monorepo
into the luxfi/safe-wallet@dev fork.

Conflicts resolved:
- yarn.lock: deleted (we are on pnpm)
- apps/web/package.json: kept pnpm version + brand build scripts
  (build:safe / build:lux / build:hanzo) plus upstream's new
  generate-version.mjs step
- apps/mobile/.../Signer/appKit.ts: took upstream's import pattern
  for shared/projectId, shared/metadata, shared/mmkvStorageAdapter

Yarn sweep applied to 42 files (docs, github-actions, workflows, AGENTS,
specs, codemods, scripts, READMEs). Net result: zero yarn-* command
references anywhere outside node_modules.

  ❯ pnpm is the law in this fork. No yarn.
2026-05-27 03:25:16 -07:00

2.0 KiB

E2E Testing Guidelines for React Native

This document outlines best practices for writing and maintaining end-to-end tests.


1. TestID Naming Convention

  • Format: Use kebab-case.
  • Suffixes: Append a suffix that indicates the element type:
    • Button: continue-button
    • Tab: home-tab
    • Input: address-input
    • Screen: settings-screen
  • Uniqueness: It's virtually impossible to have unique testIDs across the app. We should make sure that every screen has unique testIDs.
  • Exception — TestCtrls triggers: The hidden buttons in TestCtrls.e2e.tsx that seed Redux state for a scenario use the e2e<PascalCase> form (e.g. e2eConnectSignerOwner, e2eWcGateReconnect). These IDs only exist in e2e builds and are scoped to test setup, so they are kept visually distinct from product testIDs.

2. File Structure & Naming

  • Directory: Keep all e2e tests under the /e2e directory.
  • File Names: Name test files to clearly reflect the tested feature.

3. Selector Best Practices

  • Primary Selector: Rely on testIDs for selecting elements.
  • Fallbacks: Use accessibility labels only when testIDs are not available.
  • Avoid: Do not use dynamic selectors or indexes as they can lead to flaky tests.

4. Running & Debugging Tests

The easiest way to write tests is to use Maestro Studio:

  • build the app and start the the e2e metro server:
pnpm --filter @safe-global/mobile e2e:metro-ios

to run Maestro Studio:

maestro studio
  • Cross-Platform: Ideally, tests should run on both iOS and Android devices. In practice though Android tests are more flaky than iOS tests. Strive to run tests on both platforms, but prioritize iOS if necessary.

5. General Considerations

  • Maintenance: Regularly update tests to reflect UI changes.
  • Readability: Keep test code clean and well-documented.
  • Consistency: Adhere to project-wide code style and linting rules.

Happy testing!