mcpbeat Sign in

Backend Tests Agent Skill

> Use when writing unit tests under test/unit-tests/backend/*.test.ts that run in

1k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
1680
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/microsoft/vscode-cmake-tools --skill backend-tests

The instruction itself

12 sections, as written by the author

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.ts

Import 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 yields undefined
  • workspace.onDidChangeConfiguration / onDidCreateFiles / onDidDeleteFiles — no-ops
  • window.createOutputChannel / showErrorMessage / showWarningMessage — no-ops
  • commands.registerCommand / executeCommand — no-ops
  • Position, Range, Uri — minimal implementations
  • EventEmitter, 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 expectimport { 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 backendTests

Full 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.ts

Common 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.*

Other skills for the same job

different authors, same section of the catalogue
Webapp Testing
by anthropics
vendor ×12

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

6k tokens scripts
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
Test Driven Development
by w95
×7

Use when implementing any feature or bugfix, before writing implementation code

2k tokens
Systematic Debugging
by ratacat
×7

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

10k tokens scripts
Verification Before Completion
by ZhanlinCui
×6

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

1k tokens
Backtest Expert
by BaggaT236
×3

Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.

15k tokens scripts
Adaptyv
by christophacham
×3

Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.

16k tokens
Aeon
by christophacham
×3

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

19k tokens

How to use it

Copy the folder

Take microsoft/backend-tests from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.