Skip to content

Commit 8839d72

Browse files
stragllers
1 parent 448fb3d commit 8839d72

File tree

2 files changed

+124
-1890
lines changed

2 files changed

+124
-1890
lines changed

cline_docs/package-manager/implementation/06-testing-strategy.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,104 @@ The Package Manager follows a multi-layered testing approach to ensure reliabili
1212
4. **Test-Driven Development**: Writing tests before implementation when appropriate
1313
5. **Continuous Testing**: Running tests automatically on code changes
1414

15+
## Test Setup and Dependencies
16+
17+
### Required Dependencies
18+
19+
The Package Manager requires specific testing dependencies:
20+
21+
```json
22+
{
23+
"devDependencies": {
24+
"@types/jest": "^29.0.0",
25+
"@types/mocha": "^10.0.0",
26+
"@vscode/test-electron": "^2.3.8",
27+
"jest": "^29.0.0",
28+
"ts-jest": "^29.0.0"
29+
}
30+
}
31+
```
32+
33+
### E2E Test Configuration
34+
35+
End-to-end tests require specific setup:
36+
37+
```typescript
38+
// e2e/src/runTest.ts
39+
import * as path from "path"
40+
import { runTests } from "@vscode/test-electron"
41+
42+
async function main() {
43+
try {
44+
const extensionDevelopmentPath = path.resolve(__dirname, "../../")
45+
const extensionTestsPath = path.resolve(__dirname, "./suite/index")
46+
47+
await runTests({
48+
extensionDevelopmentPath,
49+
extensionTestsPath,
50+
launchArgs: ["--disable-extensions"],
51+
})
52+
} catch (err) {
53+
console.error("Failed to run tests:", err)
54+
process.exit(1)
55+
}
56+
}
57+
58+
main()
59+
```
60+
61+
### Test Framework Setup
62+
63+
```typescript
64+
// e2e/src/suite/index.ts
65+
import * as path from "path"
66+
import * as Mocha from "mocha"
67+
import { glob } from "glob"
68+
69+
export async function run(): Promise<void> {
70+
const mocha = new Mocha({
71+
ui: "tdd",
72+
color: true,
73+
timeout: 60000,
74+
})
75+
76+
const testsRoot = path.resolve(__dirname, ".")
77+
const files = await glob("**/**.test.js", { cwd: testsRoot })
78+
79+
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)))
80+
81+
try {
82+
return new Promise<void>((resolve, reject) => {
83+
mocha.run((failures) => {
84+
failures > 0 ? reject(new Error(`${failures} tests failed.`)) : resolve()
85+
})
86+
})
87+
} catch (err) {
88+
console.error(err)
89+
throw err
90+
}
91+
}
92+
```
93+
94+
### TypeScript Configuration
95+
96+
E2E tests require specific TypeScript configuration:
97+
98+
```json
99+
// e2e/tsconfig.json
100+
{
101+
"compilerOptions": {
102+
"module": "commonjs",
103+
"target": "ES2020",
104+
"lib": ["ES2020"],
105+
"sourceMap": true,
106+
"strict": true,
107+
"types": ["mocha", "node", "@vscode/test-electron"]
108+
},
109+
"exclude": ["node_modules", ".vscode-test"]
110+
}
111+
```
112+
15113
## Unit Tests
16114

17115
Unit tests focus on testing individual functions, classes, and components in isolation.

0 commit comments

Comments
 (0)