run-smoke-tests

bởi microsoft

Chạy kiểm tra smoke để xác minh chức năng mở rộng trong môi trường VS Code thực. Sử dụng khi kiểm tra các tính năng cơ bản hoạt động sau khi thay đổi.

npx skills add https://github.com/microsoft/vscode-python-environments --skill run-smoke-tests

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

ActionCommand
Run all smoke testsnpm run compile && npm run compile-tests && npm run smoke-test
Run specific testnpm run smoke-test -- --grep "Extension activates"
Debug in VS CodeDebug 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

ErrorCauseFix
Extension not installedBuild failed or ID mismatchRun npm run compile, check extension ID
Extension did not become activeError in activate()Debug with F5, check Debug Console
Command not registeredMissing from package.jsonAdd to contributes.commands
Timeout exceededSlow startup or infinite loopIncrease 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

FilePurpose
src/test/smoke/activation.smoke.test.tsExtension activation tests
src/test/smoke/index.tsTest runner entry point
src/test/testUtils.tsUtilities (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

Thêm skills từ microsoft

oss-growth
microsoft
Cá tính tăng trưởng OSS
official
accessibility-aria-expert
microsoft
Phát hiện và sửa các vấn đề về khả năng tiếp cận trong giao diện web React/Fluent UI. Sử dụng khi xem xét mã để đảm bảo tương thích với trình đọc màn hình, sửa nhãn ARIA, đảm bảo…
official
generate-canvas-app
microsoft
[DEPRECATED — sử dụng canvas-app thay thế] Tạo một ứng dụng canvas Power Apps hoàn chỉnh.
official
django
microsoft
Các phương pháp tốt nhất cho phát triển web Django bao gồm models, views, templates và testing.
official
github-issue-creator
microsoft
Chuyển đổi ghi chú thô, nhật ký lỗi, ghi âm giọng nói hoặc ảnh chụp màn hình thành báo cáo vấn đề markdown sắc nét theo phong cách GitHub. Sử dụng khi người dùng dán thông tin lỗi, lỗi…
official
python-package-management
microsoft
Sử dụng uv để quản lý phụ thuộc và poethepoet để tự động hóa tác vụ.
official
runtime-validation
microsoft
Xác thực thời gian chạy cho các ứng dụng đã di chuyển — bao gồm chiến lược kiểm thử (giai đoạn lập kế hoạch) và thực thi kiểm thử (giai đoạn xác thực): xác minh khởi động,…
official
azure-postgres-ts
microsoft
Kết nối đến Azure Database for PostgreSQL Flexible Server bằng gói pg (node-postgres) với hỗ trợ xác thực mật khẩu và Microsoft Entra ID (không mật khẩu).
official