
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@leep-frog/vscode-test-stubber
Advanced tools
The [VS Code Test CLI](https://github.com/microsoft/vscode-test-cli) makes it possible to run tests against your VS Code extension. However, it can be tricky to set up or verify interactions with the VS Code API (e.g. validating configuration changes, mim
The VS Code Test CLI makes it possible to run tests against your VS Code extension. However, it can be tricky to set up or verify interactions with the VS Code API (e.g. validating configuration changes, mimicing user interactions with prompts, etc.).
This package aims to solve that problem by stubbing out a subset of elements
of the VS Code API and exposing a UserInteraction type that allows you to
mimic user interactions in your test (e.g. selecting an item from a prompt).
All of the VS Code capabilites covered and mocked by this package are listed in the below sections. The
best way to use this package is to define a list of TestCase objects to run in
your test file and then set the appropriate fields in SimpleTestCaseProps as needed:
import {
SimpleTestCase,
SimpleTestCaseProps,
UserInteraction,
cmd,
} from "@leep-frog/vscode-test-stubber";
interface TestCase extends SimpleTestCaseProps {
name: string;
}
const testCases: TestCase[] = [
{
name: "Does something",
// Starting editor text
text: [""],
// User interactions to run
userInteractions: [
cmd("myExtension.typeHello"),
// ...
],
// Expected editor text
expectedText: ["hello"],
// etc.
},
];
suite("My Extension Test Suite", () => {
testCases.forEach((tc) => {
test(tc.name, async () => {
await new SimpleTestCase(tc.stc).runTest();
});
});
});
The below sections enumerate the components of the VS Code API that are stubbed
by this package and how to properly interact with and test them via SimpleTestCaseProps.
To set up your editor at the start of the test, use any of the following SimpleTestCaseProps:
text: If provided, starts the test with an untitled editor with the provided text (joined with newline characters)file: If provided, starts the test with an editor for the file referenced by this file pathselections: If provided, the set of cursor selections that will be configured at the start of the testIf neither
textnorfileare provided, then no text editor will be opened.
To verify elements of the active text editor at the end of your test, use the following SimpleTestCaseProps fields:
expectedText: The expected text contents (joined by newline characters) of the active text editor (or undefined if no editor is expected to be active or open).expectedSelections: The expected set of cursor selections at the end of the test.Use the following fields in SimpleTestCaseProps to verify the notifications that
were sent during the test.
expectedInfoMessagesexpectedWarningMessagesexpectedErrorMessagesSimply set the following fields in SimpleTestCaseProps:
inputBoxResponses: The list of input box responses
to return during your test execution. Note, the test will fail if there are any
unused responses.expectedInputBoxes: The expected list of input box
prompts and executions that were generated.To configure interactions with a quick pick, use the following UserInteraction
objects in your test case:
SelectItemQuickPickAction: Selects a set of itemsSelectActiveItems: Selects all currently active itemsCloseQuickPickAction: Closes the quick pickPressItemButtonQuickPickAction: Presses an item buttonPressUnknownButtonQuickPickAction: Presses an unknown item buttonTo configure interactions with a quick pick, use the following UserInteraction
objects in your test case:
SelectItemQuickPickAction: Selects a set of itemsSelectActiveItems: Selects all currently active itemsCloseQuickPickAction: Closes the quick pickPressItemButtonQuickPickAction: Presses an item buttonPressUnknownButtonQuickPickAction: Presses an unknown item buttonTo verify the quick pick configurations that were created and executed during the
test, set the expectedQuickPicks field in SimpleTestCaseProps.
Simply set the following fields in SimpleTestCaseProps:
workspaceConfiguration: The initial workspace configuration to start the test with.expectedInputBoxes: The expected workspace configuration at the end of the
test (if undefined, then verify no changes).There are additional UserInteractions aside from the ones specific to a VS Code feature mentioned in earlier sections. See the below list for additional, useful UserInteractions that can be used in your tests.
They can be imported with the following statement:
import { cmd, delay, Waiter } from "@leep-frog/vscode-test-stubber";
cmd(vscodeCommandName, ...args): This is simply a UserInteraction wrapper for VS Code command strings that
are normally executed via vscode.commands.executeCommand(cmd, ...args)Waiter(delayMs, doneFunc): This is a class that continually calls doneFunc (ever delayMs) until it returns true. This is super useful if your extension has async logic that can take a while.delay(timeInMs): This simply waits for the specified amount of time (in case you need to wait for an async operation), although it's use is not encouraged (see Waiter for a better alternative)combineInteractions(...UserInteraction): Return a single UserInteraction object that runs and waits on all provideed UserInteraction objects.FAQs
The [VS Code Test CLI](https://github.com/microsoft/vscode-test-cli) makes it possible to run tests against your VS Code extension. However, it can be tricky to set up or verify interactions with the VS Code API (e.g. validating configuration changes, mim
We found that @leep-frog/vscode-test-stubber demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.