扩展组件集成测试运行
run-integration-tests
运行集成测试以验证扩展的各个组件能否正确协同工作。在修改组件交互或事件处理后使用此技能。
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 147
- Forks
- 83
01 前言 Front Matter
- name
- run-integration-tests
- description
- Run integration tests to verify that extension components work together correctly. Use this after modifying component interactions or event handling.
03 SKILL.md 正文
Run integration tests to verify that multiple components (managers, API, settings) work together correctly.
When to Use This Skill
- After modifying how components communicate (events, state sharing)
- After changing the API surface
- After modifying managers or their interactions
- When components seem out of sync (UI shows stale data, events not firing)
Quick Reference
| Action | Command |
|---|---|
| Run all integration tests | npm run compile && npm run compile-tests && npm run integration-test |
| Run specific test | npm run integration-test -- --grep "manager" |
| Debug in VS Code | Debug panel → "Integration Tests" → F5 |
How Integration Tests Work
Integration tests run in a real VS Code instance but focus on component interactions:
- Does the API reflect manager state?
- Do events fire when state changes?
- Do different scopes return appropriate data?
They're faster than E2E (which test full workflows) but more thorough than smoke tests.
Workflow
Step 1: Compile and Run
npm run compile && npm run compile-tests && npm run integration-test
Step 2: Interpret Results
Pass:
Integration: Environment Manager + API
✓ API reflects manager state after refresh
✓ Different scopes return appropriate environments
✓ Environment objects have consistent structure
3 passing (25s)
Fail: Check error message and see Debugging section.
Debugging Failures
| Error | Cause | Fix |
|---|---|---|
API not available |
Extension activation failed | Check Debug Console |
Event not fired |
Event wiring issue | Check event registration |
State mismatch |
Components out of sync | Add logging, check update paths |
Timeout |
Async operation stuck | Check for deadlocks |
For detailed debugging: Debug panel → "Integration Tests" → F5
Adding New Integration Tests
Create files in src/test/integration/ with pattern *.integration.test.ts:
import * as assert from 'assert';
import * as vscode from 'vscode';
import { waitForCondition, TestEventHandler } from '../testUtils';
import { ENVS_EXTENSION_ID } from '../constants';
suite('Integration: [Component A] + [Component B]', function () {
this.timeout(120_000);
let api: ExtensionApi;
suiteSetup(async function () {
const extension = vscode.extensions.getExtension(ENVS_EXTENSION_ID);
assert.ok(extension, 'Extension not found');
if (!extension.isActive) await extension.activate();
api = extension.exports;
});
test('[Interaction test]', async function () {
// Test component interaction
});
});
Test Files
| File | Purpose |
|---|---|
src/test/integration/envManagerApi.integration.test.ts |
Manager + API tests |
src/test/integration/index.ts |
Test runner entry point |
src/test/testUtils.ts |
Utilities (waitForCondition, TestEventHandler) |
Prerequisites
- CI needs webpack build - Run
npm run compile(webpack) before tests, not justnpm run compile-tests(tsc) - Extension builds - Run
npm run compilebefore tests
Notes
- Integration tests are faster than E2E (30s-2min vs 1-3min)
- Focus on testing component boundaries, not full user workflows
- First run downloads VS Code (~100MB, cached in
.vscode-test/)
04 同仓库更多 Skills
VS Code 设置优先级规则
settings-precedence
VS Code 设置优先级规则及常见陷阱。适用于任何读取或写入设置的代码。涵盖 getConfiguration 作用域、inspect() 与 get() 的区别,以及多工作区处理。
VS Code 扩展冒烟测试
run-smoke-tests
运行冒烟测试,在真实 VS Code 环境中验证扩展功能。在更改后检查基本功能是否正常工作时使用。
代码提交前(pre-commit)检查
run-pre-commit-checks
在提交代码前运行强制性的 pre-commit 检查,包括 lint(代码规范检查)、类型检查和单元测试。每次提交前都必须运行。
E2E 端到端测试运行
run-e2e-tests
运行 E2E 测试以验证完整的用户工作流(如环境的发现、创建和选择)。在发布前或进行重大变更后使用此技能。
Python 环境管理器探测
python-manager-discovery
针对特定环境管理器的探测模式及已知问题。在编写或审查 conda、poetry、pipenv、pyenv 或 venv 的环境探测代码时使用。
代码库健康快照生成
generate-snapshot
生成代码库健康快照,用于技术债务追踪与规划。分析 git 历史、代码复杂度、债务标记和依赖项,以识别热点区域和重构优先级。