Skip to content

Commit a717038

Browse files
nullvariantclaude
andauthored
docs: add E2E test documentation to README, CONTRIBUTING, and AGENTS (#84)
🖥️ IDE: [Cursor](https://cursor.sh) 🔌 Extension: [Claude Code](https://claude.ai/download) Model-Raw: claude-opus-4-5-20251101 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5c13891 commit a717038

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,64 @@
44
- Scope: the entire monorepo (root-level AGENTS.md).
55
- Keep changes minimal and consistent with existing project conventions.
66
- Do not modify files unrelated to the requested task.
7+
8+
## Branch Protection
9+
10+
- **main branch**: Direct push is disabled. All changes must go through a Pull Request.
11+
- **CI checks**: The `build` check must pass before merging.
12+
- **Signed commits**: Required on main (handled by maintainers during merge).
13+
14+
## Release Process
15+
16+
Extensions are automatically published to VS Code Marketplace and Open VSX when a release tag is pushed.
17+
18+
AI agents should NOT:
19+
20+
- Push release tags
21+
- Modify version numbers in package.json without explicit instruction
22+
- Run `vsce publish` or similar commands
23+
24+
Release tags follow the format: `git-id-switcher-v1.0.0`
25+
26+
## Testing
27+
28+
### Requirements
29+
30+
- Node.js 20+
31+
32+
### Running Tests
33+
34+
```bash
35+
cd extensions/git-id-switcher
36+
37+
# Unit tests (fast, no VS Code required)
38+
npm run test
39+
40+
# E2E tests (requires VS Code download on first run)
41+
npm run test:e2e
42+
43+
# All tests
44+
npm run test && npm run test:e2e
45+
```
46+
47+
### Test Strategy
48+
49+
| Test Type | Target | When to Use |
50+
|------------|----------------------------------------------|----------------------------|
51+
| Unit Tests | Pure functions, utilities, validation | Fast feedback, edge cases |
52+
| E2E Tests | VS Code API integration, extension lifecycle | Real behavior verification |
53+
54+
### Adding E2E Tests
55+
56+
E2E test files are in `extensions/git-id-switcher/src/test/e2e/`. Guidelines:
57+
58+
1. **No mocks**: Use real VS Code APIs and Git commands
59+
2. **Cleanup**: Remove temporary files/repos after tests
60+
3. **Isolation**: Each test should be independent
61+
4. **Naming**: Use descriptive test names that explain the scenario
62+
63+
### CI/CD
64+
65+
- Unit tests: Must pass to merge PR
66+
- E2E tests: Run in parallel with build, currently non-blocking (`continue-on-error: true`)
67+
- E2E uses `xvfb-run` for headless execution on Linux

CONTRIBUTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,52 @@ npm run watch
5252

5353
## Testing
5454

55+
### Manual Testing
56+
5557
1. Open the extension folder in VS Code
5658
2. Press `F5` to launch Extension Development Host
5759
3. Test your changes manually
5860

61+
### Unit Tests
62+
63+
```bash
64+
cd extensions/git-id-switcher
65+
npm run test
66+
```
67+
68+
### E2E Tests
69+
70+
E2E (End-to-End) tests run in an actual VS Code environment using `@vscode/test-electron` and verify the extension works correctly as a whole.
71+
72+
#### Requirements
73+
74+
- Node.js 20+
75+
- On first run, VS Code will be downloaded automatically (~100MB)
76+
77+
#### Running E2E Tests
78+
79+
```bash
80+
cd extensions/git-id-switcher
81+
npm run test:e2e
82+
```
83+
84+
#### Adding E2E Tests
85+
86+
E2E test files are located in `src/test/e2e/`. When adding new E2E tests:
87+
88+
1. Create a test file in `src/test/e2e/` (e.g., `myFeature.test.ts`)
89+
2. Use the VS Code Test API (`@vscode/test-electron`)
90+
3. Test real extension behavior without mocks
91+
4. Clean up any test data after tests complete
92+
93+
#### CI/CD Integration
94+
95+
E2E tests run automatically in GitHub Actions CI:
96+
97+
- Executed in parallel with the build job
98+
- Uses `xvfb-run` for headless execution on Linux
99+
- Currently set as non-blocking (`continue-on-error: true`)
100+
59101
## Pull Request Guidelines
60102

61103
- Describe what your PR does

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,30 @@ npm run package
6262

6363
### Testing locally
6464

65+
#### Manual Testing
66+
6567
1. Open the extension folder in VS Code
6668
2. Press `F5` to launch Extension Development Host
6769
3. Test the extension in the new window
6870

71+
#### Unit Tests
72+
73+
```bash
74+
cd extensions/git-id-switcher
75+
npm run test
76+
```
77+
78+
#### E2E Tests
79+
80+
E2E tests run in an actual VS Code environment using `@vscode/test-electron`:
81+
82+
```bash
83+
cd extensions/git-id-switcher
84+
npm run test:e2e
85+
```
86+
87+
> **Note**: On first run, VS Code will be downloaded automatically (~100MB). Subsequent runs use the cached version.
88+
6989
### Git Hooks Setup
7090

7191
This repository uses custom git hooks for release safety. After cloning, run:

0 commit comments

Comments
 (0)