You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document describes the integration test setup for the Roo Code VSCode extension.
4
+
5
+
## Overview
6
+
7
+
The integration tests use the `@vscode/test-electron` package to run tests in a real VSCode environment. These tests verify that the extension works correctly within VSCode, including features like mode switching, webview interactions, and API communication.
The following global objects are available in tests:
58
+
59
+
```typescript
60
+
declareglobal {
61
+
var api:ClineAPI
62
+
var provider:ClineProvider
63
+
var extension:vscode.Extension<ClineAPI>
64
+
var panel:vscode.WebviewPanel
65
+
}
66
+
```
67
+
68
+
## Running Tests
69
+
70
+
1. Ensure you have the required environment variables set in `.env.integration`
71
+
72
+
2. Run the integration tests:
73
+
74
+
```bash
75
+
npm run test:integration
76
+
```
77
+
78
+
3. If you want to run a specific test, you can use the `test.only` function in the test file. This will run only the test you specify and ignore the others. Be sure to remove the `test.only` function before committing your changes.
79
+
80
+
The tests will:
81
+
82
+
- Download and launch a clean VSCode instance
83
+
- Install the extension
84
+
- Execute the test suite
85
+
- Report results
86
+
87
+
## Writing New Tests
88
+
89
+
When writing new integration tests:
90
+
91
+
1. Create a new test file in `src/test/suite/` with the `.test.ts` extension
92
+
93
+
2. Structure your tests using the TDD interface:
94
+
95
+
```typescript
96
+
import*asassertfrom"assert"
97
+
import*asvscodefrom"vscode"
98
+
99
+
suite("Your Test Suite Name", () => {
100
+
test("Should do something specific", asyncfunction () {
101
+
// Your test code here
102
+
})
103
+
})
104
+
```
105
+
106
+
3. Use the global objects (`api`, `provider`, `extension`, `panel`) to interact with the extension
107
+
108
+
### Best Practices
109
+
110
+
1.**Timeouts**: Use appropriate timeouts for async operations:
111
+
112
+
```typescript
113
+
const timeout =30000
114
+
const interval =1000
115
+
```
116
+
117
+
2.**State Management**: Reset extension state before/after tests:
6.**Grading**: When grading tests, use the `Grade:` format to ensure the test is graded correctly (See modes.test.ts for an example).
151
+
152
+
```typescript
153
+
awaitglobalThis.api.startNewTask(
154
+
`Given this prompt: ${testPrompt} grade the response from 1 to 10 in the format of "Grade: (1-10)": ${output} \n Be sure to say 'I AM DONE GRADING' after the task is complete`,
"For each mode (Code, Architect, Ask) respond with the mode name and what it specializes in after switching to that mode, do not start with the current mode, be sure to say 'I AM DONE' after the task is complete"
"For each mode (Code, Architect, Ask) respond with the mode name and what it specializes in after switching to that mode, do not start with the current mode, be sure to say 'I AM DONE' after the task is complete",
32
-
)
31
+
awaitglobalThis.api.startNewTask(testPrompt)
33
32
34
33
// Wait for task to appear in history with tokens.
letoutput=globalThis.provider.messages.map(({ type, text })=>(type==="say" ? text : "")).join("\n")
64
+
awaitglobalThis.api.startNewTask(
65
+
`Given this prompt: ${testPrompt} grade the response from 1 to 10 in the format of "Grade: (1-10)": ${output} \n Be sure to say 'I AM DONE GRADING' after the task is complete`,
81
66
)
82
67
83
-
assert.ok(
84
-
globalThis.provider.messages.some(
85
-
({ type, text })=>type==="say"&&text?.includes(`"request":"[switch_mode to 'ask' because:`),
86
-
),
87
-
"Did not receive expected response containing 'Roo wants to switch to ask mode'",
0 commit comments