prompttest-mobile 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +80 -0
- package/LICENSE +42 -0
- package/LICENSES.md +81 -0
- package/README.md +526 -0
- package/SECURITY.md +56 -0
- package/TERMS.md +138 -0
- package/dist/bin/prompttest.d.ts +2 -0
- package/dist/bin/prompttest.js +1418 -0
- package/dist/bin/server.d.ts +1 -0
- package/dist/constants/commands.d.ts +125 -0
- package/dist/engine.bundle.js +1039 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.js +1039 -0
- package/dist/lib/adaptive-timing.d.ts +55 -0
- package/dist/lib/adb-provisioner.d.ts +55 -0
- package/dist/lib/adb.d.ts +448 -0
- package/dist/lib/ai/heuristic-resolver.d.ts +19 -0
- package/dist/lib/ai/index.d.ts +16 -0
- package/dist/lib/ai/llm-provider.d.ts +40 -0
- package/dist/lib/ai/types.d.ts +64 -0
- package/dist/lib/baseline.d.ts +159 -0
- package/dist/lib/benchmark.d.ts +100 -0
- package/dist/lib/checkpoint.d.ts +61 -0
- package/dist/lib/ci.d.ts +49 -0
- package/dist/lib/config-loader.d.ts +87 -0
- package/dist/lib/config.d.ts +136 -0
- package/dist/lib/crawler.d.ts +335 -0
- package/dist/lib/data-loader.d.ts +53 -0
- package/dist/lib/dfs-engine.d.ts +149 -0
- package/dist/lib/dictionary.d.ts +41 -0
- package/dist/lib/doctor.d.ts +45 -0
- package/dist/lib/driver-interface.d.ts +50 -0
- package/dist/lib/enterprise.d.ts +71 -0
- package/dist/lib/errors.d.ts +68 -0
- package/dist/lib/explorer.d.ts +165 -0
- package/dist/lib/feedback.d.ts +35 -0
- package/dist/lib/form-filler.d.ts +101 -0
- package/dist/lib/ios-driver.d.ts +38 -0
- package/dist/lib/jail-guard.d.ts +59 -0
- package/dist/lib/license.d.ts +51 -0
- package/dist/lib/live-server.d.ts +52 -0
- package/dist/lib/lock.d.ts +30 -0
- package/dist/lib/logger.d.ts +68 -0
- package/dist/lib/memory.d.ts +259 -0
- package/dist/lib/patterns.d.ts +202 -0
- package/dist/lib/profiler.d.ts +75 -0
- package/dist/lib/prompt-runner.d.ts +101 -0
- package/dist/lib/quiescence.d.ts +44 -0
- package/dist/lib/recorder.d.ts +155 -0
- package/dist/lib/repl.d.ts +29 -0
- package/dist/lib/reporter.d.ts +269 -0
- package/dist/lib/runner-utils.d.ts +316 -0
- package/dist/lib/scaffold.d.ts +53 -0
- package/dist/lib/step-handlers.d.ts +390 -0
- package/dist/lib/triage.d.ts +50 -0
- package/dist/lib/wizard.d.ts +42 -0
- package/dist/lib/zip-util.d.ts +36 -0
- package/docs/ARCHITECTURE.md +154 -0
- package/docs/CLI_CONTRACT.md +131 -0
- package/docs/CLI_STUDIO_CONTRACT.md +123 -0
- package/docs/PERFORMANCE_BASELINE.md +71 -0
- package/docs/PRODUCT_STATUS.md +56 -0
- package/docs/USER_MANUAL.md +764 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
# ⚡ PromptTest Mobile
|
|
2
|
+
|
|
3
|
+
> **Ultra-fast, zero-code autonomous mobile testing & visual QA brain for Android & iOS.**
|
|
4
|
+
> The zero-setup, zero-instrumentation alternative to Appium & Detox for React Native, Expo, Flutter, and Native Android.
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/prompttest-mobile)
|
|
7
|
+
[](#-license)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](https://developer.android.com/tools/adb)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
|
|
12
|
+
> [!NOTE]
|
|
13
|
+
> **Looking for the Python LLM prompt evaluator?** That project is [`decodingchris/prompttest`](https://github.com/decodingchris/prompttest).
|
|
14
|
+
> **This is PromptTest Mobile** — the autonomous mobile application QA and visual regression testing engine for native Android & iOS mobile applications. Available on NPM as [`prompttest-mobile`](https://www.npmjs.com/package/prompttest-mobile) and [`prompttest`](https://www.npmjs.com/package/prompttest).
|
|
15
|
+
|
|
16
|
+
**PromptTest Mobile** enables QA engineers, mobile developers, and autonomous agents to test Android applications using **plain-English natural language scripts**. It completely bypasses heavy server frameworks (Appium, Selenium, WebDriver) in favor of high-speed native ADB streams, expectation-driven polling, and an autonomous state-graph exploration engine.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
### 🖥️ Prefer a Visual Desktop IDE? Try PromptTest Studio
|
|
21
|
+
|
|
22
|
+
If you prefer an intuitive desktop application over the command line, check out **[PromptTest Studio](https://shriramsingh.github.io/prompttest-studio-site/)**:
|
|
23
|
+
- 📱 **Real-Time Device Mirroring**: Low-latency screen streaming with instant click, drag, and hardware navigation.
|
|
24
|
+
- 🎯 **Visual Element Inspector**: Point and click to inspect native views with instant auto-generated plain-English assertions.
|
|
25
|
+
- 📸 **Visual Regression & Exclude Masks**: Pixel-level baseline comparisons with draggable exclude masks for dynamic areas (clocks, battery, banners).
|
|
26
|
+
- 🚀 **100% Local-First & Air-Gapped**: Runs entirely on your machine over local ADB with zero cloud dependencies.
|
|
27
|
+
|
|
28
|
+
👉 **[Download PromptTest Studio for Windows](https://shriramsingh.github.io/prompttest-studio-site/downloads.html)** *(macOS & Linux coming soon)*
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### 📑 Quick Navigation
|
|
33
|
+
|
|
34
|
+
- [🖥️ PromptTest Studio (Desktop IDE)](#️-prefer-a-visual-desktop-ide-try-prompttest-studio)
|
|
35
|
+
- [🚀 Quick Start & CLI Workflows](#-quick-start--cli-workflows)
|
|
36
|
+
- [📂 Outputs, Reports & Screenshots](#-outputs-reports--screenshots)
|
|
37
|
+
- [✍️ Writing Plain-English Tests](#️-writing-plain-english-tests)
|
|
38
|
+
- [📖 Syntax Reference](#-syntax-reference)
|
|
39
|
+
- [🛠 CLI Command Reference](#-cli-command-reference)
|
|
40
|
+
- [🎯 Mode Expectations & Limits](#-mode-expectations--limits)
|
|
41
|
+
- [💻 Programmatic TypeScript SDK](#-programmatic-typescript-sdk)
|
|
42
|
+
- [🐳 Docker Deployment](#-docker-container-deployment)
|
|
43
|
+
- [📊 Real-Device Benchmarks](#-proven-real-device-benchmarks)
|
|
44
|
+
- [📄 License](#-license)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🌟 Why PromptTest?
|
|
49
|
+
|
|
50
|
+
- 📝 **Plain-English Test Scripts**: Write tests in human language without writing fragile XPath selectors or boilerplate glue code.
|
|
51
|
+
- ⚡ **Zero-Setup & Zero-Instrumentation**: Connects directly over native ADB (USB or Wi-Fi). No SDKs, test dependencies, or code modifications required in your target app.
|
|
52
|
+
- 🤖 **Autonomous State-Graph DFS Explorer**: Crawls apps autonomously, detects bottom-tab navigation hubs, traverses nested screens, and automatically triages defects without human intervention.
|
|
53
|
+
- 💡 **Dynamic Self-Healing Locators**: Resilient heuristic matching automatically adapts to changing dynamic counts (e.g. auto-resolving `"Present (2)"` to `"Present (5)"`).
|
|
54
|
+
- 🛡 **Built-In Safety Engine**: Guards production and staging apps by blocking destructive actions (e.g., `"Delete Account"`, `"Discard Changes"`) during autonomous crawls.
|
|
55
|
+
- 📊 **Standalone HTML & JUnit Reports**: Generates executive test reports with failure-only visual screenshots and actionable error diffs.
|
|
56
|
+
- 🌐 **Built for Modern Mobile Frameworks**: Native support for **React Native**, **Expo**, **Flutter**, and Native Android (Jetpack Compose / Views).
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 🚀 Quick Start & CLI Workflows
|
|
61
|
+
|
|
62
|
+
### Prerequisites
|
|
63
|
+
|
|
64
|
+
- **Node.js 18.0.0+**
|
|
65
|
+
- **Android ADB** installed and accessible in your system `PATH`
|
|
66
|
+
- An Android device (USB or Wi-Fi) or emulator with **USB Debugging** enabled
|
|
67
|
+
|
|
68
|
+
### Install in Your Mobile Project
|
|
69
|
+
|
|
70
|
+
You can run PromptTest instantly with `npx` or install it as a dev dependency:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# In your React Native, Expo, Flutter, or Android project:
|
|
74
|
+
npm install --save-dev prompttest
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
> **⚖️ Licensing note**: PromptTest is source-available under **BSL 1.1** — free for personal, educational, open-source, and small-team use (< $100k revenue _and_ < 10 employees). Larger organizations and commercial QA agencies need a [commercial license](#-license). It converts to Apache 2.0 in 2030. See [License](#-license).
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### 5 Core CLI Workflows
|
|
82
|
+
|
|
83
|
+
#### 1. Environment Diagnostic Check
|
|
84
|
+
|
|
85
|
+
Before running tests, verify your ADB connectivity, connected devices, and permissions:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npx prompttest doctor
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### 2. Zero-Code Autonomous Exploration (AI App Crawl)
|
|
92
|
+
|
|
93
|
+
Crawl bottom tabs, lists, and forms automatically to discover bugs, crashes, or React Native red-screens without writing a single line of test code:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx prompttest explore com.yourcompany.app
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
_Tip: `explore` is its own top-level command. Pass `--max-screens=30` or `--safety-mode=strict` to customize._
|
|
100
|
+
|
|
101
|
+
#### 3. Interactive Record & Replay
|
|
102
|
+
|
|
103
|
+
Record your natural interactions on a physical phone directly into a reusable test spec:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npx prompttest record specs/login.txt
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- Tap buttons and type in input fields on your phone; PromptTest auto-generates conversational English test steps.
|
|
110
|
+
- **Append mode**: Add `--append` to add more steps to an existing spec without overwriting.
|
|
111
|
+
- **Safety backup**: If the target file already exists, PromptTest automatically creates a `.bak` backup before modifying.
|
|
112
|
+
|
|
113
|
+
#### 4. Run Plain-English Test Specs
|
|
114
|
+
|
|
115
|
+
Execute test specifications with fail-fast validation and locator self-healing:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npx prompttest run specs/login.txt com.yourcompany.app
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Power flags:
|
|
122
|
+
|
|
123
|
+
- `--heal`: Automatically self-heal altered counts and dynamic locators.
|
|
124
|
+
- `--video`: Record an MP4 video of the execution session.
|
|
125
|
+
- `--screenshots`: Capture high-resolution visual evidence at every step.
|
|
126
|
+
- `--fresh`: Cold-restart the target app before execution begins.
|
|
127
|
+
- `--embed-screenshots`: Embed screenshots directly into a standalone, shareable HTML report.
|
|
128
|
+
|
|
129
|
+
#### 5. Interactive Live REPL Playground
|
|
130
|
+
|
|
131
|
+
Experiment with commands live in your terminal against your connected device:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npx prompttest repl com.yourcompany.app
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### ⚠️ CLI Command Disambiguation Table
|
|
140
|
+
|
|
141
|
+
To avoid common syntax errors, remember that `explore`, `record`, and `repl` are **standalone commands**:
|
|
142
|
+
|
|
143
|
+
| Goal | ✅ Correct CLI Command | ❌ Common Mistake |
|
|
144
|
+
| :---------------------------- | :------------------------------------ | :--------------------------- |
|
|
145
|
+
| **Autonomous App Crawling** | `npx prompttest explore <pkg>` | `npx prompttest run explore` |
|
|
146
|
+
| **Record from Phone Touches** | `npx prompttest record <spec.txt>` | `npx prompttest run record` |
|
|
147
|
+
| **Run Existing Spec File** | `npx prompttest run <spec.txt> [pkg]` | `npx prompttest <spec.txt>` |
|
|
148
|
+
| **Interactive Live Terminal** | `npx prompttest repl [pkg]` | `npx prompttest run repl` |
|
|
149
|
+
| **Diagnostic Health Check** | `npx prompttest doctor` | `npx prompttest run doctor` |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### 📦 Recommended `package.json` Scripts
|
|
154
|
+
|
|
155
|
+
Add these convenient shortcuts to your project's `package.json`:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
"scripts": {
|
|
159
|
+
"test:mobile": "prompttest run specs/smoke.txt com.yourcompany.app --heal",
|
|
160
|
+
"test:explore": "prompttest explore com.yourcompany.app --max-screens=25",
|
|
161
|
+
"test:record": "prompttest record specs/new_flow.txt",
|
|
162
|
+
"test:doctor": "prompttest doctor"
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 📂 Outputs, Reports & Screenshots
|
|
169
|
+
|
|
170
|
+
Whenever PromptTest runs (`run`, `explore`, or `record`), all outputs are automatically organized inside an **`output/`** folder at your project root:
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
your-mobile-project/
|
|
174
|
+
├── node_modules/
|
|
175
|
+
├── specs/
|
|
176
|
+
│ └── login.txt
|
|
177
|
+
├── output/ <-- 📂 Created automatically
|
|
178
|
+
│ ├── login-report.html <-- 🌐 Interactive visual HTML report
|
|
179
|
+
│ ├── login-junit.xml <-- 🤖 CI/CD JUnit test results
|
|
180
|
+
│ ├── login-report.md <-- 📝 Markdown summary for PR comments
|
|
181
|
+
│ ├── login-results.json <-- 📊 Structured raw JSON execution metrics
|
|
182
|
+
│ ├── step_1_tap_sign_in.png <-- 📸 High-res visual screenshots
|
|
183
|
+
│ ├── login-recording.mp4 <-- 🎥 Full MP4 video (when using --video)
|
|
184
|
+
│ └── screenshots/ <-- 📸 Screen transition photos from record sessions
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Viewing & Sharing Reports:
|
|
188
|
+
|
|
189
|
+
- **Interactive HTML Dashboard (`output/<spec>-report.html`)**: Double-click to open in any browser. Features step-by-step audit timelines, latency timings, and failure triage bundles.
|
|
190
|
+
- **CI/CD Integration (`output/<spec>-junit.xml`)**: Standard JUnit format natively recognized by GitHub Actions, GitLab CI, Jenkins, and CircleCI.
|
|
191
|
+
- **Zero-Dependency Sharing (`--embed-screenshots`)**: Generates a single standalone HTML report with all images inlined via Base64 data URIs. Email or Slack it directly to teammates without missing image links!
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## ✍️ Writing Plain-English Tests
|
|
196
|
+
|
|
197
|
+
Test specifications are simple text files containing numbered steps written in conversational English.
|
|
198
|
+
|
|
199
|
+
### Example Spec (`specs/login_and_dashboard.txt`)
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
# 1. Authentication Flow
|
|
203
|
+
1. Type 'ramesh@coachconnect.app' into 'Email Address'
|
|
204
|
+
2. Type 'Teacher@1234' into 'Password'
|
|
205
|
+
3. Tap 'Sign In'
|
|
206
|
+
4. Wait 3s
|
|
207
|
+
|
|
208
|
+
# 2. Dashboard Verification
|
|
209
|
+
5. Verify 'Apex Coaching Academy' is visible
|
|
210
|
+
6. Verify 'Dr. Ramesh Sharma' is visible
|
|
211
|
+
7. Verify 'My Batches' is visible
|
|
212
|
+
|
|
213
|
+
# 3. Batches Module & Navigation
|
|
214
|
+
8. Tap 'Batches'
|
|
215
|
+
9. Verify 'Batches & Schedules' is visible
|
|
216
|
+
10. Tap 'Grade 10 Mathematics'
|
|
217
|
+
11. Verify 'Weekly Schedule' is visible
|
|
218
|
+
12. Press back
|
|
219
|
+
|
|
220
|
+
# 4. Sign Out Flow
|
|
221
|
+
13. Tap 'Profile'
|
|
222
|
+
14. Tap 'Sign Out'
|
|
223
|
+
15. Tap 'Sign Out'
|
|
224
|
+
16. Verify 'Welcome Back' is visible
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Run the Spec:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
npx prompttest run specs/login_and_dashboard.txt com.yourcompany.app
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 📖 Syntax Reference
|
|
236
|
+
|
|
237
|
+
| Category | Command Syntax | Description |
|
|
238
|
+
| :---------------- | :--------------------------------------- | :------------------------------------------------------------------ |
|
|
239
|
+
| **Tap / Click** | `Tap 'Sign In'` | Taps button, icon, link, or tab matching label or text. |
|
|
240
|
+
| **Input Fields** | `Type 'user@test.com' into 'Email'` | Auto-focuses field, clears existing text, and enters string safely. |
|
|
241
|
+
| **Assertions** | `Verify 'Dashboard' is visible` | Polls until the element appears on screen (sub-second resolution). |
|
|
242
|
+
| **Absence Check** | `Verify 'Loading...' is not visible` | Confirms an element, dialog, or spinner has dismissed. |
|
|
243
|
+
| **Spatial Tap** | `Tap 'Delete' next to 'Order #12'` | Disambiguates duplicate elements using directional proximity. |
|
|
244
|
+
| **Gestures** | `Scroll down`, `Scroll up`, `Swipe left` | Performs viewport-proportional touch flings. |
|
|
245
|
+
| **Hardware Keys** | `Press back`, `Press home` | Dispatches physical Android keycodes (`KEYCODE_BACK`, etc.). |
|
|
246
|
+
| **Delays** | `Wait 2s` or `Wait 1500ms` | Pauses execution for custom animation settling. |
|
|
247
|
+
| **Conditionals** | `Tap 'Dismiss' (if present)` | Executes step only if element exists, without failing the suite. |
|
|
248
|
+
| **Generators** | `$random.email`, `$date.now`, `$uuid` | Inlines dynamic synthetic data into input fields. |
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## 🛠 CLI Command Reference
|
|
253
|
+
|
|
254
|
+
### Primary Execution Modes
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# 1. Deterministic Spec Runner
|
|
258
|
+
npx prompttest run specs/flow.txt <package>
|
|
259
|
+
|
|
260
|
+
# Cold-restart app before suite begins
|
|
261
|
+
npx prompttest run specs/flow.txt <package> --fresh
|
|
262
|
+
|
|
263
|
+
# Capture high-resolution visual screenshots on every step
|
|
264
|
+
npx prompttest run specs/flow.txt <package> --screenshots
|
|
265
|
+
|
|
266
|
+
# Dry-run validation (checks syntax without touching device)
|
|
267
|
+
npx prompttest run specs/flow.txt --dry-run
|
|
268
|
+
|
|
269
|
+
# Display formatted table of parsed steps
|
|
270
|
+
npx prompttest run specs/flow.txt --list-steps
|
|
271
|
+
|
|
272
|
+
# Run data-driven iterations
|
|
273
|
+
npx prompttest run specs/flow.txt <package> --iterations 5
|
|
274
|
+
|
|
275
|
+
# Run against a managed device pool with concurrency leasing
|
|
276
|
+
npx prompttest run specs/flow.txt <package> --device-pool emulator-5554,emulator-5556
|
|
277
|
+
|
|
278
|
+
# Visual regression testing against gold baseline images
|
|
279
|
+
npx prompttest run specs/flow.txt --save-baseline
|
|
280
|
+
npx prompttest run specs/flow.txt --compare-baseline --baseline-threshold=0.02
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Autonomous State-Graph Explorer (`explore`)
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Autonomous exploration with Strict safety policy
|
|
287
|
+
npx prompttest explore <package>
|
|
288
|
+
|
|
289
|
+
# Set custom screen discovery and step interaction limits
|
|
290
|
+
npx prompttest explore <package> --max-screens=30 --step-budget=60
|
|
291
|
+
|
|
292
|
+
# Protect custom sensitive action keywords from being clicked
|
|
293
|
+
npx prompttest explore <package> --safety-blacklist="Wipe,Revoke,Transfer"
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Interactive Record & Replay (`record`)
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
# Record gestures, taps, and inputs directly on device into a spec
|
|
300
|
+
npx prompttest record specs/recorded_flow.txt
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Device Management & Wi-Fi Debugging
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# List all connected devices, emulators, and serial numbers
|
|
307
|
+
npx prompttest devices
|
|
308
|
+
|
|
309
|
+
# Connect to physical device wirelessly over Wi-Fi
|
|
310
|
+
npx prompttest wifi 192.168.1.50
|
|
311
|
+
|
|
312
|
+
# Inspect active screen hierarchy and detected components
|
|
313
|
+
npx prompttest status
|
|
314
|
+
|
|
315
|
+
# Run comprehensive environment diagnostic check
|
|
316
|
+
npx prompttest doctor
|
|
317
|
+
|
|
318
|
+
# View offline learned component memory graph
|
|
319
|
+
npx prompttest memory <package>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 🎯 Platform Support, Expectations & Boundaries
|
|
325
|
+
|
|
326
|
+
To maintain honest expectations, here is what PromptTest currently supports, what is under active development, and its architectural boundaries:
|
|
327
|
+
|
|
328
|
+
| Platform / Framework | Supported? | Notes |
|
|
329
|
+
| :--------------------------------- | :----------------------: | :--------------------------------------------------------------------- |
|
|
330
|
+
| **Android (Physical & Emulators)** | **✅ Production Ready** | React Native, Expo, Flutter, Native Views, Jetpack Compose. |
|
|
331
|
+
| **iOS / iPhone & iPad** | **🚧 Under Development** | Native iOS engine is in active development; not supported in v1.3.x. |
|
|
332
|
+
| **Websites / Desktop Browsers** | **❌ Not Supported** | Dedicated strictly to mobile apps. For web, use Playwright or Cypress. |
|
|
333
|
+
| **Standard UI Hierarchy** | **✅ Full** | Operates 100% via native ADB hierarchy stream (`uiautomator dump`). |
|
|
334
|
+
| **Self-Healing Dynamic Locators** | **✅ Full** | Auto-resolves modified counts and labels dynamically via `--heal`. |
|
|
335
|
+
| **Bottom-Tab Discovery** | **✅ Full** | Explores hubs, nested master-detail views, and backtracks cleanly. |
|
|
336
|
+
| **Game Engines & Canvas** | **⚠️ Not Supported** | Fully custom OpenGL/Vulkan/Unity games lack accessible UI nodes. |
|
|
337
|
+
| **Biometrics / OS Dialogs** | **⚠️ Limited** | System-level biometric prompts require hardware-level mocks. |
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## ⚠️ Common Pitfalls & How to Solve Them
|
|
342
|
+
|
|
343
|
+
### 1. Hardware Back Button Minimizing the App
|
|
344
|
+
|
|
345
|
+
- **What happens**: Running `Press back` while on the app's root dashboard or home tab tells the Android OS to minimize or exit the app.
|
|
346
|
+
- **How to solve it**:
|
|
347
|
+
- In specs, tap the in-app back icon/button (e.g. `Tap 'Back'` or `Tap '<'`) instead of the hardware key on top-level screens.
|
|
348
|
+
- In autonomous exploration (`explore`), PromptTest's built-in **Package Jail Guard** automatically detects if the app was backgrounded and restores it.
|
|
349
|
+
- Add the `--fresh` flag when running specs to cold-start your app cleanly before tests.
|
|
350
|
+
|
|
351
|
+
### 2. Android OS Permission Dialogs ("Allow Notifications / Location")
|
|
352
|
+
|
|
353
|
+
- **What happens**: System dialogs belong to Android OS (`com.android.permissioncontroller`), not your app, and can appear unexpectedly on new installs.
|
|
354
|
+
- **How to solve it**:
|
|
355
|
+
- Use conditional handling in your spec:
|
|
356
|
+
```text
|
|
357
|
+
Tap 'While using the app' (if present)
|
|
358
|
+
Tap 'Allow' (if present)
|
|
359
|
+
```
|
|
360
|
+
- Or auto-grant permissions via ADB before running tests:
|
|
361
|
+
```bash
|
|
362
|
+
adb shell pm grant com.yourcompany.app android.permission.POST_NOTIFICATIONS
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### 3. Off-Screen Items in Long Lists (FlatList / RecyclerView)
|
|
366
|
+
|
|
367
|
+
- **What happens**: Mobile frameworks only render visible items on screen to save memory. Elements located further down the page are not in the hierarchy yet.
|
|
368
|
+
- **How to solve it**:
|
|
369
|
+
- Scroll before tapping:
|
|
370
|
+
```text
|
|
371
|
+
Scroll down
|
|
372
|
+
Verify 'Save Changes' is visible
|
|
373
|
+
Tap 'Save Changes'
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### 4. Layout Animations & Shimmer Settling
|
|
377
|
+
|
|
378
|
+
- **What happens**: Tapping an element during a layout animation or skeleton fade-in can cause touch coordinates to miss while elements shift.
|
|
379
|
+
- **How to solve it**:
|
|
380
|
+
- Add a brief settling pause: `Wait 500ms` or assert an anchor element first: `Verify 'Dashboard' is visible`.
|
|
381
|
+
- Disable animations on test devices to run tests 2x faster:
|
|
382
|
+
```bash
|
|
383
|
+
adb shell settings put global window_animation_scale 0
|
|
384
|
+
adb shell settings put global transition_animation_scale 0
|
|
385
|
+
adb shell settings put global animator_duration_scale 0
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### 5. WebViews & In-App Browsers (OAuth & Payment Gateways)
|
|
389
|
+
|
|
390
|
+
- **What happens**: In-app web pages (like Google Sign-In or Stripe) expose rendered text to ADB, but not internal HTML DOM tags or CSS selectors.
|
|
391
|
+
- **How to solve it**:
|
|
392
|
+
- Use plain text matching (`Tap 'Sign in with Google'`). Deep DOM selector manipulation inside WebViews is not supported.
|
|
393
|
+
|
|
394
|
+
### 6. Multiple Devices Connected
|
|
395
|
+
|
|
396
|
+
- **What happens**: If a physical phone and an emulator are both plugged in, ADB doesn't know which one to target.
|
|
397
|
+
- **How to solve it**:
|
|
398
|
+
- Target a specific device serial using `--serial`:
|
|
399
|
+
```bash
|
|
400
|
+
npx prompttest run specs/login.txt com.app --serial=emulator-5554
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
## 💡 Pro-Tips & Best Practices
|
|
406
|
+
|
|
407
|
+
### 1. The "Record & Refine" Workflow
|
|
408
|
+
|
|
409
|
+
- `prompttest record` captures your natural physical device interactions and generates plain-English test steps in real time—scaffolding 90% of your test boilerplate in seconds.
|
|
410
|
+
- **QA Best Practice**: After recording, do a quick 30-second review of the generated `.txt` spec to fine-tune timings or add custom `Verify` assertions.
|
|
411
|
+
- Preview without touching your device:
|
|
412
|
+
```bash
|
|
413
|
+
npx prompttest run specs/flow.txt --dry-run
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### 2. Deterministic Clean States (`--fresh`)
|
|
417
|
+
|
|
418
|
+
- Prevent "already-logged-in" test pollution by adding `--fresh` to cold-start the target app before execution:
|
|
419
|
+
```bash
|
|
420
|
+
npx prompttest run specs/login.txt com.yourcompany.app --fresh
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### 3. Zero-Maintenance Dynamic Badges (`--heal`)
|
|
424
|
+
|
|
425
|
+
- When notification badges or counts change dynamically (e.g. `'Cart (1)'` vs `'Cart (3)'`), pass `--heal` to allow PromptTest's heuristic engine to self-heal the locator without failing.
|
|
426
|
+
|
|
427
|
+
### 4. Device & Screen Resolution Agnostic Portability
|
|
428
|
+
|
|
429
|
+
- PromptTest binds interactions to semantic accessibility labels and proportional gestures—not fragile hardware pixel coordinates. Specs recorded on a phone seamlessly run on foldables and tablets.
|
|
430
|
+
|
|
431
|
+
### 5. 🛡️ Enterprise Safety Guardrails & Custom Blacklists
|
|
432
|
+
|
|
433
|
+
Autonomous exploration is safe by default, but enterprise applications often have company-specific sensitive keywords (e.g. _"Deactivate"_, _"Transfer Funds"_, _"Revoke Access"_).
|
|
434
|
+
|
|
435
|
+
- **Default Protection**: PromptTest automatically detects and blocks destructive actions like `"Delete"`, `"Wipe"`, `"Remove"`, and `"Discard Changes"`.
|
|
436
|
+
- **Add Your Own Sensitive Keywords**: You can supply your own custom blocked keywords to run **alongside** the defaults:
|
|
437
|
+
```bash
|
|
438
|
+
# Via CLI flag:
|
|
439
|
+
npx prompttest explore com.yourcompany.app --safety-blacklist="Transfer,Deactivate,Revoke,Unsubscribe"
|
|
440
|
+
```
|
|
441
|
+
- **Or configure once in `.prompttestrc.json`**:
|
|
442
|
+
```json
|
|
443
|
+
{
|
|
444
|
+
"safety": {
|
|
445
|
+
"mode": "strict",
|
|
446
|
+
"customBlacklist": ["Transfer", "Deactivate", "Revoke", "Unsubscribe"]
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## 💻 Programmatic TypeScript SDK
|
|
454
|
+
|
|
455
|
+
PromptTest exports a full programmatic SDK for embedding into Node.js test runners or custom CI scripts:
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
import { createPromptRunner, createAndroidDriver } from 'prompttest';
|
|
459
|
+
|
|
460
|
+
// Initialize native ADB driver for connected device
|
|
461
|
+
const driver = createAndroidDriver('DEVICE_SERIAL');
|
|
462
|
+
const runner = createPromptRunner(driver);
|
|
463
|
+
|
|
464
|
+
// Execute spec and retrieve structured execution report
|
|
465
|
+
const report = await runner.runSpec('specs/login.txt', 'com.example.app', {
|
|
466
|
+
fresh: true,
|
|
467
|
+
screenshots: 'failure-only',
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
console.log(`Execution complete: ${report.passedSteps}/${report.totalSteps} passed.`);
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## 🐳 Docker Container Deployment
|
|
476
|
+
|
|
477
|
+
PromptTest is containerized with Android platform-tools and headless runtime support:
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
# Build container image
|
|
481
|
+
docker build -t prompttest .
|
|
482
|
+
|
|
483
|
+
# Execute test spec inside container sharing host ADB daemon
|
|
484
|
+
docker run --rm --net=host \
|
|
485
|
+
-v $(pwd)/specs:/app/specs \
|
|
486
|
+
-v $(pwd)/output:/app/output \
|
|
487
|
+
prompttest run specs/flow.txt com.example.app
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## 📊 Proven Real-Device Benchmarks
|
|
493
|
+
|
|
494
|
+
Tested and verified against live physical Android devices running complex multi-role enterprise apps:
|
|
495
|
+
|
|
496
|
+
| Test Suite | Total Steps | Passed | Failed | Pass Rate | Execution Time |
|
|
497
|
+
| :-------------------------------- | :---------: | :----: | :----: | :-------: | :------------: |
|
|
498
|
+
| **CoachConnect Enterprise Suite** | 52 | 52 | 0 | **100%** | 47.8s |
|
|
499
|
+
| **Govindam Multilingual Suite** | 8 | 8 | 0 | **100%** | 35.1s |
|
|
500
|
+
| **Calculator Operations Suite** | 5 | 5 | 0 | **100%** | 19.6s |
|
|
501
|
+
| **Automated Vitest Test Matrix** | 294 | 294 | 0 | **100%** | 14.8s |
|
|
502
|
+
|
|
503
|
+
_For deep architectural details and driver design, see `docs/ARCHITECTURE.md` included in the package._
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## 📄 License
|
|
508
|
+
|
|
509
|
+
PromptTest is licensed under the **Business Source License 1.1 (BSL 1.1)**, and automatically converts to the permissive **Apache License 2.0** on the Change Date: **September 14, 2030**.
|
|
510
|
+
|
|
511
|
+
**✅ Free to use — no license required for:**
|
|
512
|
+
|
|
513
|
+
- Personal, educational, academic, and open-source projects
|
|
514
|
+
- Evaluation use
|
|
515
|
+
- Internal software testing within organizations that have **both** under $100,000 USD in annual gross revenue **and** fewer than 10 employees
|
|
516
|
+
|
|
517
|
+
**💼 Commercial license required for:**
|
|
518
|
+
|
|
519
|
+
- Use within organizations exceeding either of the free-tier thresholds (revenue **or** headcount)
|
|
520
|
+
- Testing agencies providing commercial QA services to third-party clients
|
|
521
|
+
- Deployment into production commercial CI/CD pipelines
|
|
522
|
+
- Offering PromptTest (modified or unmodified) as a hosted or managed QA/cloud testing service
|
|
523
|
+
|
|
524
|
+
See the full [LICENSE](./LICENSE) and [Terms & Conditions](./TERMS.md) for exact terms.
|
|
525
|
+
|
|
526
|
+
Commercial inquiries and enterprise licensing: `jairam.singh9@gmail.com` or open an issue at [github.com/shriramsingh/prompttest-community](https://github.com/shriramsingh/prompttest-community/issues).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Security & Compliance Policy
|
|
2
|
+
|
|
3
|
+
PromptTest is built with enterprise security, local execution privacy, and data isolation at its foundation.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Local-First Architecture Guarantee
|
|
8
|
+
|
|
9
|
+
- **Zero Telemetry**: PromptTest does **not** collect, phone-home, or transmit usage metrics, telemetry, crash reports, or device serials to external cloud servers.
|
|
10
|
+
- **Offline By Default**: Core test execution, OCR/UI parsing, accessibility hierarchy processing, and self-healing memory operate 100% locally via ADB and offline deterministic heuristics.
|
|
11
|
+
- **Opt-in AI**: External LLM providers (OpenAI, Anthropic) are strictly opt-in and disabled by default. When enabled, only stripped element text fragments necessary for intent matching are transmitted; full app memory or credential payloads are never forwarded. Local model inference (e.g. Ollama via `PROMPTTEST_AI_BASE_URL`) is fully supported for air-gapped environments.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 2. Reporting Vulnerabilities
|
|
16
|
+
|
|
17
|
+
If you discover a security vulnerability within PromptTest or its dependencies, please disclose it responsibly.
|
|
18
|
+
|
|
19
|
+
- **Security Contact**: Email security reports privately to `security@prompttest.dev` (or open a confidential security advisory on GitHub).
|
|
20
|
+
- **Response SLA**:
|
|
21
|
+
- Initial acknowledgment: within **24 hours**.
|
|
22
|
+
- Triage and impact assessment: within **72 hours**.
|
|
23
|
+
- Remediation patch release: within **7 days** for critical/high vulnerabilities.
|
|
24
|
+
- **Public Disclosure**: We kindly ask that you do not disclose the vulnerability publicly until a patch has been published.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 3. Secret & Credential Handling Best Practices
|
|
29
|
+
|
|
30
|
+
When writing PromptTest specifications and configuring CI/CD pipelines:
|
|
31
|
+
|
|
32
|
+
1. **Never Hardcode Secrets in Specs**:
|
|
33
|
+
Use runtime variables (`--var:KEY=VAL`) or environment variables instead of hardcoding API keys, OTP codes, or passwords directly in `.txt` test files.
|
|
34
|
+
```bash
|
|
35
|
+
npx prompttest run specs/login.txt --var:USER=$TEST_USER --var:PASS=$TEST_PASS
|
|
36
|
+
```
|
|
37
|
+
2. **Sanitize Data-Driven Test Fixtures**:
|
|
38
|
+
Store data files in `.gitignore` if they contain sensitive real-world records. Ensure `test-data.json` and credentials are never checked into version control.
|
|
39
|
+
3. **Automated Secret Masking**:
|
|
40
|
+
PromptTest automatically masks input values targeting elements associated with passwords, PINs, auth tokens, or private secrets in execution logs and HTML reports.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 4. Execution Sandboxing
|
|
45
|
+
|
|
46
|
+
- **JavaScript Execution**: Custom JS hooks (`run js: ...`) execute in an isolated V8 context without direct access to Node.js `child_process`, `fs`, or network APIs.
|
|
47
|
+
- **ADB Boundaries**: ADB execution is strictly scoped to test automation verbs (`shell input`, `shell uiautomator`, `shell am`, `shell pm`). Arbitrary device shell injection is prohibited.
|
|
48
|
+
- **Concurrency Mutex**: Device-level file locking ensures concurrent test jobs cannot collide, cross-contaminate device states, or intercept parallel device streams.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 5. Dependency & Supply Chain Security
|
|
53
|
+
|
|
54
|
+
- **Strict Audit Gate**: CI enforces `npm audit --audit-level=high` on every pull request and build.
|
|
55
|
+
- **Zero Copyleft**: All runtime dependencies are strictly licensed under permissive open-source licenses (MIT / ISC / Apache-2.0).
|
|
56
|
+
- **Minimal Surface**: Production dependencies are strictly minimized (`chalk`, `pixelmatch`, `pngjs`) to minimize supply chain exposure.
|