vitest-midscene-e2e
web-infra-dev/midscene-skills
Midscene을 활용해 Vitest의 기능을 강화하여 웹(Playwright), 안드로이드(ADB), iOS(WDA) 환경에서 AI 기반의 UI 테스트를 수행할 수 있도록 지원합니다. 자연어로 된 UI 상호작용을 통해 새로운 프로젝트를 구성하고 기존 프로젝트를 변환할 수 있으며, E2E 테스트를 생성·업데이트·디버깅·실행할 수도 있습니다. 지원되는 작업 명령어는 다음과 같습니다: write test, add test, create test, update test, fix test, debug test, run test, e2e test, midscene test, new project, convert project, init project, 写测试, 加测试, 创建测试, 更新测试, 修复测试, 调试测试, 运行测试, 新建工程, 转化工程.
...모든 것을 확장하십시오vitest-midscene-e2e에 대하여
vitest-midscene-e2e는 Midscene을 활용해 Vitest 테스트 프레임워크를 강화함으로써, 웹(Playwright Chromium), 안드로이드(ADB 및 scrcpy), iOS(WebDriverAgent) 환경에서 AI 기반의 자연어 기반 엔드투엔드 UI 테스트를 구축할 수 있게 해줍니다. 이 도구는 세렉터 기반의 E2E 테스트가 가지는 취약점을 해결합니다. 기존에는 사용자 흐름을 쉽게 깨질 수 있는 탭 및 입력 작업들로 나누어 처리했지만, 이 도구를 사용하면 테스터는 일반 언어로 된 의도를 Midscene의 에이전트에 전달하기만 하면 되며, 해당 에이전트가 상호작용을 계획하고 실행합니다. 이 기술은 새로운 테스트 프로젝트를 구축하거나 기존 프로젝트를 변환할 수 있을 뿐만 아니라, 테스트를 생성, 업데이트, 디버깅 및 실행할 수 있으며, 영어와 중국어로 된 트리거 문구도 지원합니다.
작업 흐름은 먼저 제공된 스크립트를 통해 표준 보일러플레이트를 클론한 뒤, 현재 프로젝트와 비교하여 사용자가 필요로 하는 플랫폼에만 부족한 부분을 채워 넣습니다. 기존 설정은 덮어쓰지 않으며, .env.example 파일을 .env 파일로 복사해 사용자가 내용을 입력할 수 있도록 합니다. 이 도구의 핵심 원칙은 사용자가 설명한 UI 단계들을 세부적인 aiTap/aiInput/aiAssert 호출 대신 주요 api인 aiAct를 통해 구현해야 한다는 점입니다. 이를 통해 AI가 계획 수립, 결과 확인, 데이터 추출 및 대기 작업을 처리할 수 있습니다. 문서에는 동일한 AI 메서드를 공유하는 플랫폼별 에이전트 클래스, 페이지나 단계 경계에 따라 긴 프롬프트를 분할하는 방법, fileChooserAllowedDir로 제한된 파일 업로드 규칙(프로젝트 루트나 홈 디렉터리 사용 금지), 테스터의 전문성을 설정할 수 있는 aiActionContext 시스템 프롬프트 옵션, 피해야 할 일반적인 로케이터 오류 사례, 그리고 오류 해결을 위한 참고 자료가 포함되어 있습니다.
주요 사용자는 웹, 안드로이드, iOS 환경에서 안정적이고 자연어 기반의 자동화 테스트를 원하는 크로스플랫폼 E2E 테스트를 작성하는 개발자와 QA 엔지니어들입니다. 이 도구를 실행하려면 Midscene용 AI 모델 자격 증명을 포함한 환경 변수 설정과 Playwright, ADB, WebDriverAgent와 같은 플랫폼별 도구 체인이 필요합니다. 이 기술은 클론 스크립트를 실행해 테스트를 수행하지만, 합법적인 테스트 작업 흐름에만 적용되며, 너무 광범위한 경로를 노출하기보다는 파일 업로드 디렉터리를 좁게 설정할 것을 권장합니다.
자주 묻는 질문
어떤 플랫폼을 지원하나요?
웹은 Playwright Chromium을 통해, 안드로이드는 ADB 및 scrcpy를 통해, iOS는 WebDriverAgent를 통해 지원됩니다. 웹 환경에서는 ctx.agent와 ctx.page 둘 다 제공되며, 안드로이드와 iOS에서는 ctx.agent만 제공됩니다. 세 가지 플랫폼의 에이전트들은 모두 동일한 AI 메서드를 공유합니다.
테스트 단계는 어떻게 작성하나요?
aiTap, aiInput, aiAssert로 나누어 처리하는 대신, 사용자의 의도를 자연어 형태로 주요 API인 aiAct에 전달하면 됩니다. aiAct는 결과 확인, 데이터 추출 및 대기 작업도 함께 처리하므로, 더 이상 사용되지 않는 aiAction 대신 aiAct를 사용해야 합니다.
어떤 설정이 필요한가요?
제공된 스크립트를 사용해 보일러플레이트를 클론한 뒤, 필요한 의존성을 설치하고 .env.example 파일에서 복사한 .env 파일에 Midscene용 AI 모델 자격 증명을 포함한 필요한 변수들을 설정해야 합니다. 또한 Playwright, ADB/scrcpy, WebDriverAgent와 같은 해당 플랫폼용 도구 체인도 필요합니다.
파일 업로드는 어떻게 안전하게 처리되나요?
aiAct 프롬프트를 통해 파일을 업로드할 때, 해당 테스트에 필요한 파일들이 포함된 가장 작은 디렉터리를 fileChooserAllowedDir로 지정해야 합니다. 문서에서는 명시적으로 프로젝트 루트나 홈 디렉터리 사용을 금지하고 있습니다.
프롬프트에 여러 단계가 포함된 경우는 어떻게 하나요?
흐름 중간에 AI가 맥락을 잃지 않도록, 페이지나 단계 경계에 따라 프롬프트를 별도의 aiAct 호출들로 나누어야 합니다. 동시에 모든 단계가 원래의 의도와 일치하도록 해야 합니다. 오류 해결을 위한 참고 자료도 함께 제공됩니다.
모든 파일
3개의 파일 SKILL.md 7.0 KB View scripts/clone-boilerplate.sh 1.2 KB View references/troubleshooting.md 2.2 KB View
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.sh
The 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
aiActto 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 APIsawait ctx.agent.aiInput('search box', { value: 'iPhone' });await ctx.agent.aiTap('search button');// CORRECT — pass intent directly to aiActawait 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 operationsawait 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 aiActawait ctx.agent.aiAct('verify the page shows "Login successful"');await ctx.agent.aiAct('verify the error message is visible');
Prompt-driven File Uploads (Web only)
When an aiAct prompt asks Midscene to upload files, pass fileChooserAllowedDir explicitly. Use the smallest directory containing that test case's fixtures, and refer to files relative to it in the prompt. Do not use the project root or a home directory. Replace ./fixtures below with the fixture directory relative to the test process working directory.
await ctx.agent.aiAct( 'click the upload button and upload avatar.png', { fileChooserAllowedDir: './fixtures' },);
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-wayawait 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 "[email protected]", change phone to "13800000000", click save, wait for success');// Correct — split by page/stage boundary, each phase stays within one logical contextawait 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 "[email protected]", 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— useaiActinstead - 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
- In
node_modules/@midscene/web,node_modules/@midscene/android, andnode_modules/@midscene/ios, find the type definitions for the agent classes - If types are not enough, follow the source references in the
.d.tsfiles to read the implementation code innode_modules - Download https://midscenejs.com/llms.txt, then use
grepto search for the API or concept you need (the file is large, do not read it in full)
모든 파일
3개 파일vitest-midscene-e2e 설치
해당 스킬 파일들을 다운로드하여 .claude/skills/ 디렉토리에 압축을 풀어 저장해 주세요.
ZIP 다운로드저장소를 클론하고 스킬 파일을 프로젝트에 복사하세요.
git clone https://github.com/web-infra-dev/midscene-skills/blob/main/skills/vitest-midscene-e2e/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
복사





집
