extension-testing

Test VS Code extensions with Mocha and @vscode/test-electron.

Updated Feb 24, 2026
One-click install
npx skills add https://github.com/fabioc-aloha/Extensions --skill extension-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: extension-testing
Source: https://github.com/fabioc-aloha/Extensions/tree/main/.github/skills/extension-testing
Command: npx skills add https://github.com/fabioc-aloha/Extensions --skill extension-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a comprehensive guide and reusable patterns for effectively testing VS Code extensions, ensuring their reliability and quality.

Core Features & Use Cases

  • Unit Testing: Learn to test pure TypeScript logic using Mocha.
  • Integration Testing: Understand how to test extension activation, commands, and VS Code API interactions with @vscode/test-electron.
  • Mocking VS Code APIs: Discover techniques for isolating your code by mocking VS Code services.
  • Use Case: You've developed a new VS Code extension and need to ensure all its commands function correctly and its core logic is robust before publishing.

Quick Start

Run the tests for your VS Code extension using the command npm test.

Frequently Asked Questions about extension-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test VS Code extension commands and API interactions?

To test VS Code extension commands and API interactions, you can use integration testing strategies with `@vscode/test-electron` to validate extension activation and command execution within a real editor environment. This ensures robust extension validation.

What is the best way to unit test VS Code extension logic?

Unit testing VS Code extension logic is best achieved using Mocha to test pure TypeScript code. By mocking VS Code APIs, you isolate your core logic to ensure your extension codebase is reliable and maintainable without needing a live editor instance.

How do I mock VS Code APIs for isolated testing?

Mocking VS Code APIs involves isolating your code by mocking VS Code services, which allows you to test pure TypeScript logic independently. This technique prevents direct reliance on the live editor environment during your Mocha unit tests.

Can I use Mocha for VS Code extension integration testing?

Yes, you can use Mocha for VS Code extension integration testing. While Mocha handles the test suite structure, `@vscode/test-electron` facilitates the integration tests for extension activation and VS Code API interactions.

Does VS Code extension testing support CI configuration?

Yes, VS Code extension testing supports CI configuration. The testing strategy covers setting up CI to run your Mocha unit tests and `@vscode/test-electron` integration tests, ensuring robust extension validation automatically on every code change.

Why do I need @vscode/test-electron for my extension tests?

You need `@vscode/test-electron` to run integration tests that validate extension activation and VS Code API interactions. It provides the necessary editor environment required to verify commands function correctly before publishing.