AGENT SKILL

VS Code 扩展冒烟测试

run-smoke-tests

运行冒烟测试,在真实 VS Code 环境中验证扩展功能。在更改后检查基本功能是否正常工作时使用。

适用职业测试工程师
License 许可
MIT
最近更新
2026-11-14
Stars
★ 147
Forks
83

01 前言 Front Matter

name
run-smoke-tests
description
Run smoke tests to verify extension functionality in a real VS Code environment. Use this when checking if basic features work after changes.

03 SKILL.md 正文

Run smoke tests to verify the extension loads and basic functionality works in a real VS Code environment.

When to Use This Skill

  • After making changes to extension activation code
  • After modifying commands or API exports
  • Before submitting a PR to verify nothing is broken
  • When the user asks to "run smoke tests" or "verify the extension works"

Quick Reference

Action Command
Run all smoke tests npm run compile && npm run compile-tests && npm run smoke-test
Run specific test npm run smoke-test -- --grep "Extension activates"
Debug in VS Code Debug panel → "Smoke Tests" → F5

How Smoke Tests Work

Unlike unit tests (which mock VS Code), smoke tests run inside a real VS Code instance:

  1. npm run smoke-test uses @vscode/test-cli
  2. The CLI downloads a standalone VS Code binary (cached in .vscode-test/)
  3. It launches that VS Code with your extension installed
  4. Mocha runs test files inside that VS Code process
  5. Results are reported back to your terminal

This is why smoke tests are slower (~10-60s) but catch real integration issues.

Workflow

Step 1: Compile and Run

npm run compile && npm run compile-tests && npm run smoke-test

Step 2: Interpret Results

Pass: 4 passing (2s) → Extension works, proceed.

Fail: See error message and check Debugging section.

Running Individual Tests

To run a specific test instead of the whole suite:

# By test name (grep pattern)
npm run smoke-test -- --grep "Extension activates"

# Or temporarily add .only in code:
test.only('Extension activates without errors', ...)

Debugging Failures

Error Cause Fix
Extension not installed Build failed or ID mismatch Run npm run compile, check extension ID
Extension did not become active Error in activate() Debug with F5, check Debug Console
Command not registered Missing from package.json Add to contributes.commands
Timeout exceeded Slow startup or infinite loop Increase timeout or check for blocking code

For detailed debugging, use VS Code: Debug panel → "Smoke Tests" → F5

Adding New Smoke Tests

Create a new file in src/test/smoke/ with the naming convention *.smoke.test.ts:

import * as assert from 'assert';
import * as vscode from 'vscode';
import { waitForCondition } from '../testUtils';
import { ENVS_EXTENSION_ID } from '../constants';

suite('Smoke: [Feature Name]', function () {
    this.timeout(60_000);

    test('[Test description]', async function () {
        // Arrange
        const extension = vscode.extensions.getExtension(ENVS_EXTENSION_ID);
        assert.ok(extension, 'Extension not found');

        // Ensure extension is active
        if (!extension.isActive) {
            await extension.activate();
        }

        // Act
        const result = await someOperation();

        // Assert
        assert.strictEqual(result, expected, 'Description of what went wrong');
    });
});

Key patterns:

  • Use waitForCondition() instead of sleep() for async assertions
  • Set generous timeouts (this.timeout(60_000))
  • Include clear error messages in assertions

Test Files

File Purpose
src/test/smoke/activation.smoke.test.ts Extension activation tests
src/test/smoke/index.ts Test runner entry point
src/test/testUtils.ts Utilities (waitForCondition, etc.)

Prerequisites

  • CI needs webpack build: The extension must be built with npm run compile (webpack) before tests run. The test runner uses dist/extension.js which is only created by webpack, not by npm run compile-tests (tsc)
  • Extension builds: Run npm run compile before tests

Notes

  • First run downloads VS Code (~100MB, cached in .vscode-test/)
  • Tests auto-retry once on failure

04 同仓库更多 Skills

microsoft
microsoft/vscode-python-environments

VS Code 设置优先级规则

settings-precedence

VS Code 设置优先级规则及常见陷阱。适用于任何读取或写入设置的代码。涵盖 getConfiguration 作用域、inspect() 与 get() 的区别,以及多工作区处理。

软件开发工程师开发环境与工具链管理
★ 147
microsoft
microsoft/vscode-python-environments

代码提交前(pre-commit)检查

run-pre-commit-checks

在提交代码前运行强制性的 pre-commit 检查,包括 lint(代码规范检查)、类型检查和单元测试。每次提交前都必须运行。

软件开发工程师代码仓库协作管理
★ 147
microsoft
microsoft/vscode-python-environments

扩展组件集成测试运行

run-integration-tests

运行集成测试以验证扩展的各个组件能否正确协同工作。在修改组件交互或事件处理后使用此技能。

测试工程师测试与质量保障
★ 147
microsoft
microsoft/vscode-python-environments

E2E 端到端测试运行

run-e2e-tests

运行 E2E 测试以验证完整的用户工作流(如环境的发现、创建和选择)。在发布前或进行重大变更后使用此技能。

测试工程师测试与质量保障
★ 147
microsoft
microsoft/vscode-python-environments

Python 环境管理器探测

python-manager-discovery

针对特定环境管理器的探测模式及已知问题。在编写或审查 conda、poetry、pipenv、pyenv 或 venv 的环境探测代码时使用。

软件开发工程师开发环境与工具链管理
★ 147
microsoft
microsoft/vscode-python-environments

代码库健康快照生成

generate-snapshot

生成代码库健康快照,用于技术债务追踪与规划。分析 git 历史、代码复杂度、债务标记和依赖项,以识别热点区域和重构优先级。

软件开发工程师代码仓库协作管理
★ 147