
Vitest Midscene E2e
- 1.7k installs
- 283 repo stars
- Updated August 3, 2026
- web-infra-dev/midscene-skills
AI-powered end-to-end testing framework combining Vitest (TypeScript test runner) and Midscene (natural-language UI automation) for Web, Android, and iOS platforms.
About
Vitest Midscene E2E integrates Vitest with Midscene's AI-driven UI automation to scaffold and test multi-platform applications (Web via Playwright, Android via ADB, iOS via WDA). Developers describe UI actions and assertions in natural language; the `aiAct` API translates these into executable interactions without fragile selectors. Provides project scaffolding from a boilerplate reference, supports test creation/update/debugging/execution, and includes platform-specific context classes (`WebTest`, `AndroidTest`, `IOSTest`) that expose agent instances and lifecycle hooks. Mandatory rule: pass user intent directly to `aiAct` rather than decomposing into fine-grained APIs.
- Multi-platform support: Web (Playwright), Android (ADB + scrcpy), iOS (WebDriverAgent) in one unified test framework
- Natural-language UI interactions via `aiAct` API - describe actions and assertions without CSS/XPath selectors
- Project scaffolding from boilerplate reference with platform-specific context classes and test conventions
- Integrated debugging and troubleshooting via built-in references and mandatory setup validation before writing tests
- Supports test creation, updates, runs, and conversion of existing projects to Midscene E2E structure
Vitest Midscene E2e by the numbers
- 1,653 all-time installs (skills.sh)
- +55 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #455 of 2,153 Testing & QA skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
vitest-midscene-e2e capabilities & compatibility
- Capabilities
- create e2e test files with natural language ui d · update existing test suites using `aiact` patter · debug failing tests via troubleshooting referenc · run tests across web, android, ios platforms · scaffold new projects from boilerplate · convert existing projects to midscene e2e struct
- Works with
- github · playwright
- Use cases
- testing · ui design · debugging
- Platforms
- macOS · Windows · Linux
- Runs
- Runs locally
- Pricing
- Free
npx skills add https://github.com/web-infra-dev/midscene-skills --skill vitest-midscene-e2eAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.7k |
|---|---|
| repo stars | ★ 283 |
| Security audit | 2 / 3 scanners passed |
| Last updated | August 3, 2026 |
| Repository | web-infra-dev/midscene-skills ↗ |
What it does
Write and run AI-powered end-to-end tests for web, Android, and iOS apps using natural-language UI interactions instead of brittle selectors.
Who is it for?
Testing web apps (Chrome via Playwright), Android apps (ADB), iOS apps (WDA); refactoring existing projects to AI-driven E2E; writing maintainable cross-platform test suites.
Skip if: Unit testing; integration testing of backend APIs alone; performance/load testing; static analysis.
When should I use this skill?
Developer needs to write/update/debug/run E2E tests; scaffold new project for E2E testing; convert existing project to Midscene structure.
What you get
Developers write and execute multi-platform E2E tests using natural-language descriptions of UI interactions; Midscene's AI handles selector resolution and execution planning automatically.
- Corrected aiAct prompts with embedded waits
- Aligned timeout configuration
By the numbers
- Supports 3 platforms: Web, Android, iOS
- Primary API: `aiAct` method for all UI operations
- Boilerplate reference: `~/.midscene/boilerplate/vitest-all-platforms-demo/`
Files
Vitest Midscene E2E
Modules
| Module | Role |
|---|---|
| Vitest | TypeScript test framework. Provides describe/it/expect/hooks for test organization, assertions, and lifecycle. |
| Midscene | AI-driven UI automation. Interacts with UI elements via natural language — no fragile selectors. Core API: aiAct. |
Supported platforms:
- Web —
WebTest(Playwright Chromium):ctx.agent+ctx.page - Android —
AndroidTest(ADB + scrcpy):ctx.agentonly - iOS —
IOSTest(WebDriverAgent):ctx.agentonly
Workflow
Step 1: Clone boilerplate & ensure project ready
bash scripts/clone-boilerplate.shThe boilerplate at ~/.midscene/boilerplate/vitest-all-platforms-demo/ is the canonical reference for project structure, configs, platform context classes, and test conventions. Compare the current project against it. If anything is missing, ask the user which platform(s) they need (Web / Android / iOS), then fill in what's missing using the boilerplate as the target state. Only include files for the requested platform(s). Do NOT overwrite existing configs or files. Copy .env.example from the boilerplate as .env if it doesn't exist, and prompt the user to fill in the env vars.
Step 2: Read the Midscene Agent API section below before writing tests
It contains mandatory rules for using aiAct — the primary API for all UI operations. Do NOT skip this step.
Step 3: Create, update, or run tests
Use the boilerplate's e2e/ directory and src/context/ as reference for patterns and conventions. Before running tests, ensure dependencies are installed and .env is configured. When debugging failures, check troubleshooting.md.
Midscene Agent API
ctx.agent is a platform-specific agent instance. All methods return Promises.
- Web:
PlaywrightAgentfrom@midscene/web/playwright - Android:
AndroidAgentfrom@midscene/android - iOS:
IOSAgentfrom@midscene/ios
All three agents share the same AI methods below.
Mandatory Rule: Use aiAct for User-Described Steps
When the user describes a UI action or state confirmation in natural language, you MUST use `aiAct` to implement it. Do NOT decompose user instructions intoaiTap/aiInput/aiAssertor other fine-grained APIs. Pass the user's intent directly toaiActand let Midscene's AI handle the planning and execution.
// User says: "type iPhone in the search box and click search"
// WRONG — manually decomposing into fine-grained APIs
await ctx.agent.aiInput('search box', { value: 'iPhone' });
await ctx.agent.aiTap('search button');
// CORRECT — pass intent directly to aiAct
await ctx.agent.aiAct('type "iPhone" in the search box, then click the search button');Assertions, data extraction, and waiting should also be done via aiAct — it handles all of these. Do NOT use aiAssert, aiQuery, aiWaitFor, aiTap, or aiInput separately.
aiAct(taskPrompt, opt?) — Primary API
`aiAct` is the primary API for all UI operations and state confirmations. It accepts natural language instructions and autonomously plans and executes multi-step interactions.
// UI operations
await ctx.agent.aiAct('type "iPhone" in the search box, then click the search button');
await ctx.agent.aiAct('hover over the user avatar in the top right');
// State confirmations / assertions — also use aiAct
await ctx.agent.aiAct('verify the page shows "Login successful"');
await ctx.agent.aiAct('verify the error message is visible');Phase splitting: If the task prompt is too long or covers multiple distinct stages, split it into separate aiAct calls — one per phase. Each phase should be a self-contained logical step, and all phases combined must match the user's original intent.
// Incorrect — prompt spans multiple pages and too many steps, AI may lose context mid-way
await ctx.agent.aiAct('click the settings button in the top nav, go to settings page, find personal info and click into it, change email to "test@example.com", change phone to "13800000000", click save, wait for success');
// Correct — split by page/stage boundary, each phase stays within one logical context
await ctx.agent.aiAct('click the settings button in the top nav, go to settings page, find personal info and click into it');
await ctx.agent.aiAct('change email to "test@example.com", change phone to "13800000000", click save');
await ctx.agent.aiAct('verify the save success message appears');aiActionis deprecated. UseaiActoraiinstead.
Common Mistakes
- Vague locators —
'button'is ambiguous; use'the blue "Submit" button at the top of the page' - Deprecated `aiAction` — use
aiActinstead - Ambiguous multi-element targets — specify row/position:
'the delete button in the first product row'
Agent Configuration — aiActionContext
aiActionContext is a system prompt string appended to all AI actions performed by the agent. Use it to define the AI's role and expertise.
// Set via agentOptions in setup()
const ctx = WebTest.setup('https://example.com', {
agentOptions: {
aiActionContext: 'You are a Web UI testing expert.',
},
});Good examples:
'You are a Web UI testing expert.''You are an Android app testing expert who is familiar with Chinese UI.'
Bad examples:
'Click the login button.'— specific actions belong inaiAct(), notaiActionContext'The page is in Chinese.'— this is page description, not a system prompt
How to Look Up More
1. In node_modules/@midscene/web, node_modules/@midscene/android, and node_modules/@midscene/ios, find the type definitions for the agent classes 2. If types are not enough, follow the source references in the .d.ts files to read the implementation code in node_modules 3. Download https://midscenejs.com/llms.txt, then use grep to search for the API or concept you need (the file is large, do not read it in full)
Troubleshooting
Timeout / Assertion Too Early
AI-driven tests are slower than selector-based tests. Default timeout is 180s per test. Most timeout and premature assertion failures are caused by not waiting for the page/app to be ready.
Include waiting in the aiAct prompt itself, so Midscene waits for the page/app to be ready before asserting:
// Incorrect — assertion fires before page updates
await ctx.agent.aiAct('click the submit button');
await ctx.agent.aiAct('verify the page shows "Submission successful"');
// Correct — include wait in the action prompt
await ctx.agent.aiAct('click the submit button and wait until the submission completes');
await ctx.agent.aiAct('verify the page shows "Submission successful"');---
Element Not Found / Wrong Element
Vague or ambiguous descriptions cause AI to match the wrong element or fail entirely.
// Incorrect — too vague, multiple buttons may exist
await ctx.agent.aiAct('click the button');
await ctx.agent.aiAct('click the delete button');
// Correct — include position, context, or visual traits
await ctx.agent.aiAct('click the blue "Submit" button at the top of the page');
await ctx.agent.aiAct('click the delete button in the first product row');Tips for precise descriptions:
- Include position: top / bottom / first row / left side
- Include text content: "Submit" / "Confirm" / "Delete"
- Include visual traits: blue / large / with icon
---
Device Connection
Android — ensure a device is connected and ADB is configured:
adb devices # Should list your deviceIf using a remote device, set MIDSCENE_ADB_REMOTE_HOST and MIDSCENE_ADB_REMOTE_PORT in .env.
iOS — ensure WebDriverAgent is running on the target device/simulator:
curl http://localhost:8100/statusOverride the port via IOSTest.setup(uri, { deviceOptions: { wdaPort: 8100 } }).
---
Debugging Tips
- Headed mode (Web): Use
WebTest.setup(url, { headless: false })to see the browser during test execution - Midscene report: Check the generated report for screenshots and AI decision traces
#!/bin/bash
# Clone or update the Midscene boilerplate from the external repo.
# First run: clones the repo. Subsequent runs: pulls once per day.
# Usage: bash scripts/clone-boilerplate.sh
BOILERPLATE_DIR="$HOME/.midscene/boilerplate"
MARKER="$BOILERPLATE_DIR/.last_updated"
# Fresh clone if directory doesn't exist
if [ ! -d "$BOILERPLATE_DIR" ]; then
git clone --depth 1 --branch main --filter=blob:none --sparse \
https://github.com/web-infra-dev/midscene-example.git "$BOILERPLATE_DIR"
cd "$BOILERPLATE_DIR" || exit 1
git sparse-checkout set vitest-all-platforms-demo
date +%s > "$MARKER"
echo "Boilerplate cloned to $BOILERPLATE_DIR/vitest-all-platforms-demo/"
exit 0
fi
# Update if last pull was more than 1 day ago
NOW=$(date +%s)
LAST_UPDATED=$(cat "$MARKER" 2>/dev/null || echo 0)
ELAPSED=$(( NOW - LAST_UPDATED ))
ONE_DAY=86400
if [ "$ELAPSED" -ge "$ONE_DAY" ]; then
echo "Boilerplate outdated (last update >1 day ago), pulling latest..."
cd "$BOILERPLATE_DIR" && git fetch --depth 1 origin main 2>/dev/null && git pull --ff-only origin main 2>/dev/null || echo "Update failed, using existing boilerplate."
date +%s > "$MARKER"
else
echo "Boilerplate is up to date."
fi
Related skills
How it compares
Pick vitest-midscene-e2e for AI-driven Midscene flakes; pick standard Playwright debugging skills for selector-based E2E without aiAct.
FAQ
When should I use `aiAct` vs fine-grained APIs like `aiTap` or `aiInput`?
Always use `aiAct` when the user describes a UI action or state confirmation in natural language. Pass the full intent directly to `aiAct` and let Midscene's AI plan and execute. Do NOT decompose user instructions into separate fine-grained API calls.
What platforms does Vitest Midscene E2E support?
Web (Playwright Chromium), Android (ADB + scrcpy), and iOS (WebDriverAgent). Each has a dedicated context class: `WebTest`, `AndroidTest`, `IOSTest`.
How do I start a new Vitest Midscene project?
Run `bash scripts/clone-boilerplate.sh` to fetch the canonical boilerplate at `~/.midscene/boilerplate/vitest-all-platforms-demo/`. Compare your project against it, select your target platforms (Web/Android/iOS), fill in missing files, and copy `.env.example` to `.env` with requi
Is Vitest Midscene E2e safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.