@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Function createMockExtensionContext

    • Creates a focused vscode.ExtensionContext fixture for activation-unit tests: a real (empty) subscriptions array, working globalState/workspaceState mementos and secrets storage, and plausible placeholders for members used by this kit.

      The returned value is assignable to the supported @types/vscode shape, but it is not a complete runtime implementation. Paths are placeholders, mementos/secrets are in-memory, extension metadata is synthetic, and environment-variable/language-model members are spies. Prefer createTestHost when code only needs the framework plan; use this fixture for a direct activate(context) boundary.

      vscode.Uri has a private constructor, and a couple of nested shapes (Extension<any>, GlobalEnvironmentVariableCollection) are approximated rather than fully implemented — there is no real extension host in a unit test. Both are collapsed into the single documented cast below, so callers receive a properly typed vscode.ExtensionContext without having to cast at every call site themselves.

      Parameters

      Returns ExtensionContext

      import { vi } from 'vitest';
      import { createMockExtensionContext } from '@kkdev92/vscode-ext-kit/testing';

      const context = createMockExtensionContext(vi);
      activate(context);
      expect(context.subscriptions).toHaveLength(1);