测试与安全

capacitor-testing

cap-go/capgo-skills

Testing guide for Capacitor apps and plugins. Covers web-layer unit and component tests with Vitest and mocked Capacitor plugins (`vi.mock('@capacitor/core')`, `registerPlugin`), Playwright for the web build, Appium E2E with NATIVE_APP / WEBVIEW context switching, native plugin unit tests with Swift Testing vs XCTest (what can migrate, `CAPPluginCall` patterns, `xcodebuild test` on a simulator) and Android JUnit, plus an agent-driven verification loop on simulators and devices (build, install, launch, screenshot, UI hierarchy, tap, logs) with `xcrun simctl`, `xcrun devicectl`, `adb`, Xcode MCP device tools, and live reload via `npx cap run --url` (Capacitor 9) or `-l --host --port` (Capacitor 8). Use when adding tests, mocking plugins, "does it work on device", verifying a UI change on a simulator, migrating XCTest to Swift Testing, or setting up test CI. Do not use for crash log capture (ios-android-logs), WebView debugging sessions (debugging-capacitor), or build pipelines (capacitor-ci-cd).

  • 1316 次安装
  • 74 星标
  • 收录于

安装命令

npx skills add https://github.com/cap-go/capgo-skills --skill capacitor-testing

SKILL.md

Testing Capacitor Apps and Plugins

A Capacitor app has three layers to test: the web app (most logic), the native bridge and plugins (Swift/Kotlin), and the running app on a device. Pick the cheapest layer that can catch the bug.

When to Use

TRIGGER when:

  • Adding unit, component or E2E tests to a Capacitor app
  • Mocking Capacitor or plugin APIs in Vitest / Jest
  • Writing or modernizing native unit tests for a plugin (Swift Testing, XCTest, JUnit)
  • Verifying a change on a simulator, emulator or device ("test this", "does it work", "check on device")
  • E2E tests that cannot find web elements in the app (WebView context)
  • Setting up test jobs in CI

Do not use:

  • Reading device or crash logs: ios-android-logs
  • Safari Web Inspector / Chrome DevTools debugging: debugging-capacitor
  • Build, signing and release pipelines: capacitor-ci-cd
  • App Intents tests: capacitor-app-intents (AppIntentsTesting)