Loading...
Loading...
Enhances Vitest with Midscene for AI-powered UI testing across Web (Playwright), Android (ADB), and iOS (WDA). Scaffolds new projects, converts existing projects, and creates/updates/debugs/runs E2E tests using natural-language UI interactions. Triggers: write test, add test, create test, update test, fix test, debug test, run test, e2e test, midscene test, new project, convert project, init project, 写测试, 加测试, 创建测试, 更新测试, 修复测试, 调试测试, 运行测试, 新建工程, 转化工程.
npx skill4agent add web-infra-dev/midscene-skills vitest-midscene-e2e| Module | Role |
|---|---|
| Vitest | TypeScript test framework. Provides |
| Midscene | AI-driven UI automation. Interacts with UI elements via natural language — no fragile selectors. Core API: |
WebTestctx.agentctx.pageAndroidTestctx.agentIOSTestctx.agentbash scripts/clone-boilerplate.sh~/.midscene/boilerplate/vitest-all-platforms-demo/.env.example.envaiActe2e/src/context/.envctx.agentPlaywrightAgent@midscene/web/playwrightAndroidAgent@midscene/androidIOSAgent@midscene/iosaiActWhen the user describes a UI action or state confirmation in natural language, you MUST useto implement it. Do NOT decompose user instructions intoaiAct/aiTap/aiInputor other fine-grained APIs. Pass the user's intent directly toaiAssertand let Midscene's AI handle the planning and execution.aiAct
// 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');aiActaiAssertaiQueryaiWaitForaiTapaiInputaiAct// 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');aiAct// 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');is deprecated. UseaiActionoraiActinstead.ai
'button''the blue "Submit" button at the top of the page'aiActionaiAct'the delete button in the first product row'aiActionContextaiActionContext// Set via agentOptions in setup()
const ctx = WebTest.setup('https://example.com', {
agentOptions: {
aiActionContext: 'You are a Web UI testing expert.',
},
});'You are a Web UI testing expert.''You are an Android app testing expert who is familiar with Chinese UI.''Click the login button.'aiAct()aiActionContext'The page is in Chinese.'node_modules/@midscene/webnode_modules/@midscene/androidnode_modules/@midscene/ios.d.tsnode_modulesgrep