|
|
1 неделя назад | |
|---|---|---|
| .. | ||
| src | dba76f51e7 fix(e2e): add alwaysAllow config for MCP time server tools (#10733) | 1 неделя назад |
| .env.local.sample | 58a0efa9e1 Move e2e into apps (#3823) | 8 месяцев назад |
| .vscode-test.mjs | 58a0efa9e1 Move e2e into apps (#3823) | 8 месяцев назад |
| README.md | dbf206f06b feat(e2e): Enable E2E tests - 39 passing tests (#10720) | 1 неделя назад |
| eslint.config.mjs | 58a0efa9e1 Move e2e into apps (#3823) | 8 месяцев назад |
| package.json | 3171ffc809 Move more types to @roo-code/types (for the cli) (#10583) | 1 неделя назад |
| tsconfig.esm.json | e66136f1aa Add a new @roo-code/types package and use it everywhere (#3912) | 8 месяцев назад |
| tsconfig.json | e66136f1aa Add a new @roo-code/types package and use it everywhere (#3912) | 8 месяцев назад |
End-to-end tests for the Roo Code VSCode extension using the VSCode Extension Test Runner.
From the project root:
pnpm install
Create a .env.local file in this directory:
cd apps/vscode-e2e
cp .env.local.sample .env.local
Edit .env.local and add your OpenRouter API key:
OPENROUTER_API_KEY=sk-or-v1-your-key-here
The E2E tests require the extension and its dependencies to be built:
# From project root
pnpm -w bundle
pnpm --filter @roo-code/vscode-webview build
Or use the test:ci script which handles this automatically (recommended).
cd apps/vscode-e2e
pnpm test:ci
This command:
Expected output: ~39 passing tests, ~0 skipped tests, ~6-8 minutes
TEST_FILE="task.test" pnpm test:ci
Available test files:
extension.test - Extension activation and command registrationtask.test - Basic task executionmodes.test - Mode switching functionalitymarkdown-lists.test - Markdown renderingsubtasks.test - Subtask handlingtools/write-to-file.test - File writing tooltools/read-file.test - File reading tooltools/search-files.test - File search tooltools/list-files.test - Directory listing tooltools/execute-command.test - Command execution tooltools/apply-diff.test - Diff application tooltools/use-mcp-tool.test - MCP tool integrationTEST_GREP="markdown" pnpm test:ci
This will run only tests whose names match "markdown".
For faster iteration during test development:
Build dependencies once:
pnpm -w bundle
pnpm --filter @roo-code/vscode-webview build
Run tests directly (faster, but requires manual rebuilds):
pnpm test:run
Note: If you modify the extension code, you must rebuild before running test:run.
apps/vscode-e2e/
├── src/
│ ├── runTest.ts # Test runner entry point
│ ├── suite/
│ │ ├── index.ts # Test suite setup and configuration
│ │ ├── utils.ts # Test utilities (waitFor, etc.)
│ │ ├── test-utils.ts # Test configuration helpers
│ │ ├── extension.test.ts
│ │ ├── task.test.ts
│ │ ├── modes.test.ts
│ │ ├── markdown-lists.test.ts
│ │ ├── subtasks.test.ts
│ │ └── tools/ # Tool-specific tests
│ │ ├── write-to-file.test.ts
│ │ ├── read-file.test.ts
│ │ ├── search-files.test.ts
│ │ ├── list-files.test.ts
│ │ ├── execute-command.test.ts
│ │ ├── apply-diff.test.ts
│ │ └── use-mcp-tool.test.ts
│ └── types/
│ └── global.d.ts # Global type definitions
├── .env.local.sample # Sample environment file
├── .env.local # Your API key (gitignored)
├── package.json
├── tsconfig.json # TypeScript config for tests
└── README.md # This file
Test Runner (runTest.ts):
.vscode-test/)Test Setup (suite/index.ts):
api object for testsTest Execution:
RooCodeAPI to programmatically control the extensionCleanup:
Cause: The @roo-code/types package hasn't been built.
Solution: Use pnpm test:ci instead of pnpm test:run, or build dependencies manually:
pnpm -w bundle
pnpm --filter @roo-code/vscode-webview build
Cause: The extension bundle hasn't been created.
Solution: Build the extension:
pnpm -w bundle
Possible causes:
Solution:
Cause: Missing or incorrect .env.local file.
Solution: Create .env.local with your API key:
echo "OPENROUTER_API_KEY=sk-or-v1-your-key-here" > .env.local
Cause: Network issues or GitHub rate limiting.
Solution: The test runner has retry logic. If it continues to fail:
.vscode-test/ directoryAs of the last run:
Most tool tests are currently skipped. These need to be investigated and re-enabled:
import * as assert from "assert"
import { RooCodeEventName } from "@roo-code/types"
import { waitUntilCompleted } from "./utils"
import { setDefaultSuiteTimeout } from "./test-utils"
suite("My Test Suite", function () {
setDefaultSuiteTimeout(this)
test("Should do something", async () => {
const api = globalThis.api
// Start a task
const taskId = await api.startNewTask({
configuration: {
mode: "code",
autoApprovalEnabled: true,
},
text: "Your task prompt here",
})
// Wait for completion
await waitUntilCompleted({ api, taskId })
// Assert results
assert.ok(true, "Test passed")
})
})
waitFor(condition, options) - Wait for a condition to be truewaitUntilCompleted({ api, taskId }) - Wait for task completionwaitUntilAborted({ api, taskId }) - Wait for task abortionsleep(ms) - Sleep for specified millisecondssetDefaultSuiteTimeout(context) - Set 2-minute timeout for suiteThe globalThis.api object provides:
// Task management
api.startNewTask({ configuration, text, images })
api.resumeTask(taskId)
api.cancelCurrentTask()
api.clearCurrentTask()
// Interaction
api.sendMessage(text, images)
api.pressPrimaryButton()
api.pressSecondaryButton()
// Configuration
api.getConfiguration()
api.setConfiguration(values)
// Events
api.on(RooCodeEventName.TaskStarted, (taskId) => {})
api.on(RooCodeEventName.TaskCompleted, (taskId) => {})
api.on(RooCodeEventName.Message, ({ taskId, message }) => {})
// ... and many more events
The E2E tests run automatically in GitHub Actions on:
mainmainSee .github/workflows/code-qa.yml for the CI configuration.
Requirements:
OPENROUTER_API_KEY secret must be configured in GitHubSet environment variable to see detailed logs:
DEBUG=* pnpm test:ci
VSCode logs are written to the console during test execution. Look for:
The test workspace is created in /tmp/roo-test-workspace-* and deleted after tests.
To preserve it for debugging, modify runTest.ts:
// Comment out this line:
// await fs.rm(testWorkspace, { recursive: true, force: true })
TEST_FILE="extension.test" pnpm test:ci
This helps identify if issues are test-specific or systemic.
When adding new E2E tests:
teardown() hooksIf you encounter issues: