add-test
Generate unit or E2E test files for existing code
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Generate unit or E2E test files for existing code
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use for one-off / single-question inspection of the running GitLens extension — examining UI state, reading logs, checking feature flags, dispatching a command, or asking "what does the live DOM look like right now". Reference for `vscode-inspector` MCP primitives. For iterative debug-and-fix loops on UI bugs (sweep → fix → re-verify), use `/live-exercise` instead.
Use whenever any UI-bearing work touches a running instance — building or fixing a feature, ship-gating, auditing, OR debugging visible bugs (flaky behavior, intermittent rendering, "sometimes does X" reports, hover/focus/animation glitches, layout overflow). Adaptive depth from tactical fix-loop to ship-gate audit. Not for pure-logic diff review.
Use to audit a component, file, or directory for WCAG 2.1 AA accessibility compliance. Detects ARIA anti-patterns, missing semantics, keyboard gaps, and color-only information. Safety-first — refuses to emit fixes that would create a new accessibility bug. Scope is always explicit; do not use for page-level flow or cross-program planning.
Use to audit a page, view, or composed flow for WCAG 2.1 AA compliance at the composition level - landmarks, heading hierarchy, tab order across components, focus handoff on modal open/close, live-region conflicts. Scope is page/view, NOT component internals. Safety-first - refuses to emit fixes that would create a new a11y bug. For single-component audits use /a11y-audit; for cross-program planning use /a11y-remediate.
Use to produce a leader-facing remediation proposal from one or more /a11y-audit outputs plus team and product context. Translates audit findings into sprint plans, staffing asks, customer-facing language, compliance rollups, and critical-path analysis. Refuses to fabricate numbers, owners, or commitments beyond the inputs it has.
Add new icons to the GitLens GL Icons font
| name | add-test |
| description | Generate unit or E2E test files for existing code |
/add-test [type] [target]
type — unit (default) or e2etarget — File path or feature name to testCreates src/path/__tests__/file.test.ts:
import * as assert from 'assert';
import { functionToTest } from '../file.js';
suite('FeatureName Test Suite', () => {
suite('functionName', () => {
test('should handle normal input', () => {
const result = functionToTest('input');
assert.strictEqual(result, 'expected');
});
test('should handle edge case', () => {
const result = functionToTest('');
assert.strictEqual(result, undefined);
});
test('should throw on invalid input', () => {
assert.throws(() => functionToTest(null), /error message/);
});
});
suite('async function', () => {
test('should resolve with data', async () => {
const result = await asyncFunction();
assert.deepStrictEqual(result, { key: 'value' });
});
});
});
When mocking is needed, use sinon:
import * as sinon from 'sinon';
let sandbox: sinon.SinonSandbox;
setup(() => {
sandbox = sinon.createSandbox();
});
teardown(() => {
sandbox.restore();
});
Creates tests/e2e/specs/feature.test.ts:
import { test as base, createTmpDir, expect, GitFixture, MaxTimeout } from '../baseTest.js';
const test = base.extend({
vscodeOptions: [
{
vscodeVersion: process.env.VSCODE_VERSION ?? 'stable',
setup: async () => {
const repoDir = await createTmpDir();
const git = new GitFixture(repoDir);
await git.init();
await git.commit('Initial commit', 'README.md', '# Test');
return repoDir;
},
},
{ scope: 'worker' },
],
});
test.describe('Feature Name', () => {
test.describe.configure({ mode: 'serial' });
test.afterEach(async ({ vscode }) => {
await vscode.gitlens.resetUI();
});
test('should display feature correctly', async ({ vscode }) => {
await vscode.gitlens.openGitLensSidebar();
await expect(vscode.page.getByRole('heading')).toContainText('Expected');
});
});
__tests__/ directory if neededassert.strictEqual(), assert.deepStrictEqual(), assert.ok(), assert.throws()Use the MCP server to explore, then write the test. Don't guess at selectors — verify them live.
/live-inspect to launch VS Code and discover the right selectors:
launch {}
execute_command { command: "gitlens.showHomeView" }
aria_snapshot {} # See all UI elements and roles
inspect_dom { selector: "h1", in_webview: true } # Find webview content
screenshot {} # Visual verification
inspect_dom to verify element text/visibilityevaluate to check extension runtime statescreenshot to visually confirm UI stateexpect(locator).toBeVisible(), .toContainText(), .toHaveCount()Use getGitLensWebview(title, purpose) to get a FrameLocator for webview content:
const webview = await vscode.gitlens.getGitLensWebview('Home', 'webviewView');
await expect(webview!.locator('h1')).toContainText('Expected heading');
await expect(webview!.getByRole('button', { name: /Try Pro/i })).toBeVisible();
Available webviews: Home, Graph, Graph Details, Inspect, Visual File History, Interactive Rebase.
Purpose is webviewView (sidebar/panel) or webviewPanel (editor tab) or customEditor.
// Simulate Pro subscription for the test
using _ = await vscode.gitlens.startSubscriptionSimulation({
state: 6 /* SubscriptionState.Paid */,
planId: 'pro',
});
// Pro features now accessible — auto-reverts when scope exits
await git.init()
await git.commit(message, fileName, content)
await git.branch(name)
await git.checkout(name, create?)
await git.tag(name, { message?, ref? })
await git.stash(message?)
await git.worktree(path, branch)
await git.addRemote(name, url)
await git.merge(branch, message?)
pnpm run test -- --grep "FeatureName" # Unit
pnpm run test:e2e -- tests/e2e/specs/file.test.ts # E2E
For detailed test running patterns, output interpretation, and debugging: see docs/testing.md.