backend-tests
Skill1.7k starsChanged 7 months agoMITView on GitHub
Use when writing unit tests under test/unit-tests/backend/*.test.ts that run in Node with Mocha+Chai and no VS Code API. For pure logic: parsers, helpers, env merging. Triggers: "backend test", "unit test", "mocha test without vscode".
1 other project uses a version of this.
Trending
Quiet this year.thin dataabout the whole repository
Most recently taken up by
- vstorm-co/agenticostheir own version, first seen Sep 13, 2026
Who's talking about microsoft/vscode-cmake-tools
- clangd/vscode-clangd“support commands in settings”GitHub · Jun 27, 2020 · 17 reactions
- fredericbonnet/cmake-test-explorer“trigger BuildBeforeRun also by running a test in the testexplorer”GitHub · Mar 12, 2021 · 8 reactions
- twxs/vs.language.cmake“CMake Tools Extension & twxs.cmake extension”GitHub · Jan 29, 2024 · 5 reactions
- disroop/vs-code-conan“configuration provider for cpptools / IntelliSense”GitHub · Jan 14, 2021 · 3 reactions
- microsoft/vscode-cmake-tools-api“Update APIs”GitHub · Aug 1, 2025 · 2 reactions
The biggest 5 of 14 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 14
Talked about on GitHub (14 times).
On GitHub · 14
- Jun 27, 2020support commands in settings — clangd/vscode-clangd17 reactions · 8 comments
- Mar 12, 2021trigger BuildBeforeRun also by running a test in the testexplorer — fredericbonnet/cmake-test-explorer8 reactions
- Jan 29, 2024CMake Tools Extension & twxs.cmake extension — twxs/vs.language.cmake5 reactions · 1 comment
- Jan 14, 2021configuration provider for cpptools / IntelliSense — disroop/vs-code-conan3 reactions · 5 comments
- Aug 1, 2025Update APIs — microsoft/vscode-cmake-tools-api2 reactions · 4 comments
9 more on GitHub
- Nov 15, 2024Add C++26 support (setting values only) — microsoft/vscode-cpptools2 reactions · 3 comments
- Oct 25, 2024cmake-kits.json incorrect CXX compiler — raspberrypi/pico-vscode2 reactions · 3 comments
- Oct 24, 2024Add support for `${command:<name-of-command>}` in c_cpp_properties.json — microsoft/vscode-cpptools2 reactions · 7 comments
- Feb 28, 2022Add support for resolving commands — microsoft/vscode-cpptools2 reactions · 4 comments
- Jun 19, 2025Cleanup standard version handling. — microsoft/vscode-makefile-tools1 reaction
- Mar 5, 2025Pixi builds / VSCode / CMake issues and differences — FreeCAD/FreeCAD1 reaction · 15 comments
- Jan 31, 2025Feature request: Improved variable and command substitution for build directories setting — JacquesLucke/gcov-viewer1 reaction
- Sep 26, 2024Replace CMake grammar — github-linguist/linguist1 reaction
- Sep 16, 2024Newest macos-latest environment update not working for VS Code tests — actions/runner-images1 reaction · 2 comments
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- vstorm-co/agenticos★ 54same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository7 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- add-commandSkill
- add-diagnostic-parserSkill
- add-settingSkill
- presets-vs-kitsSkill
- pr-readinessSkill
- validation-projectSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Use backend tests for pure logic that has no VS Code UI interaction.
- Very specific: line 38
Import directly via the @cmt/* path alias.
- Very specific: line 69
Add a comment like // --- Mirror of <module>.<function> --- so reviewers can trace back to the source.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Writing Backend Tests
Recipe for adding backend (unit) tests that run without VS Code.
When to use backend tests
Use backend tests for pure logic that has no VS Code UI interaction. They are the fastest feedback loop — no Extension Host, no display server, just Node + Mocha.
Good candidates: string manipulation, path logic, parsers, encoding, variable expansion, data-structure helpers, environment merging.
Not suitable for: anything that calls vscode.window.*, vscode.workspace.* beyond
getConfiguration(), or depends on an active editor.
File location
test/unit-tests/backend/<name>.test.tsImport strategy — decision tree
Module has NO transitive vscode dependency
Import directly via the @cmt/* path alias.
// encoding.test.ts — encodingUtils has no vscode imports
import { isValidUtf8 } from '@cmt/encodingUtils';Module transitively imports vscode
Mirror the pure function logic inline in the test file. Do not import the
source module — it will fail because vscode cannot be resolved at test time
(even with the mock, deep transitive chains can break).
// expand.test.ts — expand.ts transitively depends on vscode
// Mirror of expand.substituteAll
function substituteAll(input: string, subs: Map<string, string>) {
let finalString = input;
let didReplacement = false;
subs.forEach((value, key) => {
if (value !== key) {
const pattern = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const re = new RegExp(pattern, 'g');
finalString = finalString.replace(re, value);
didReplacement = true;
}
});
return { result: finalString, didReplacement };
}Add a comment like // --- Mirror of <module>.<function> --- so reviewers
can trace back to the source.
What setup-vscode-mock.ts provides
The mock is auto-loaded via Mocha's -r flag. It intercepts require('vscode') and
returns stubs for:
workspace.getConfiguration()— returns a Proxy that yieldsundefinedworkspace.onDidChangeConfiguration/onDidCreateFiles/onDidDeleteFiles— no-opswindow.createOutputChannel/showErrorMessage/showWarningMessage— no-opscommands.registerCommand/executeCommand— no-opsPosition,Range,Uri— minimal implementationsEventEmitter,Disposable,TreeItem,ThemeIcon— stubs
This lets some modules with shallow vscode dependencies work. If your module only
touches vscode.workspace.getConfiguration(), direct import may still work. Test it —
if it fails, fall back to the mirror pattern.
Test framework
| Aspect | Value |
| Runner | Mocha |
| Style | TDD — use suite() / test(), not describe() / it() |
| Assertions | Chai expect — import { expect } from 'chai' |
| Path aliases | @cmt/* → src/*, @test/* → test/* |
Skeleton — direct import pattern
import { expect } from 'chai';
import { myFunction } from '@cmt/myModule';
suite('[myFunction]', () => {
test('does the expected thing', () => {
const result = myFunction('input');
expect(result).to.equal('expected');
});
test('handles edge case', () => {
expect(myFunction('')).to.equal('');
});
});Skeleton — mirror pattern
import { expect } from 'chai';
/**
* Tests for pure utility functions in src/someModule.ts.
* Functions are mirrored here because someModule.ts transitively
* depends on 'vscode'.
*/
// --- Mirror of someModule.helperFn ---
function helperFn(input: string): string {
// Copy the implementation verbatim from the source
return input.trim().toLowerCase();
}
suite('[helperFn]', () => {
test('trims and lowercases', () => {
expect(helperFn(' Hello ')).to.equal('hello');
});
test('empty string', () => {
expect(helperFn('')).to.equal('');
});
});Run command
yarn backendTestsFull command (for reference):
node ./node_modules/mocha/bin/_mocha \
-u tdd \
--timeout 999999 \
--colors \
-r ts-node/register \
-r tsconfig-paths/register \
-r test/unit-tests/backend/setup-vscode-mock.ts \
./test/unit-tests/backend/**/*.test.tsCommon pitfalls
| Pitfall | Fix |
Cannot find module 'vscode' | Module has a transitive vscode dependency — use the mirror pattern |
suite is not defined | Mocha TDD interface not loaded — ensure you run via yarn backendTests, not mocha directly |
Import path uses relative ../../../src/ | Use @cmt/* alias instead — tsconfig-paths/register resolves it |
describe/it used instead of suite/test | This project uses Mocha TDD style — switch to suite/test |
Mock returns undefined for a config value | setup-vscode-mock.ts's getConfiguration() returns undefined for everything — if your code needs a real value, you may need to extend the mock or restructure |
See also: .github/copilot-instructions.md for project-wide conventions.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

