DSH Quality
Intermediate
3 min read

Testing Strategies for DSH Plugins

Testing Strategies for DSH Plugins — Learn how to build intermediate dsh plugins.

Last updated: 2026-08-29

Test your plugin in isolation

The hardest part about testing dsh plugins is that ctx is a runtime object. The solution: mock ctx and test your registration logic independently.

ts
import { describe, it, expect } from 'vitest';

describe('my-plugin', () => {
  it('registers hello command', () => {
    const mockCtx = { commands: { register: vi.fn() } };
    apply(mockCtx as any, {});
    expect(mockCtx.commands.register).toHaveBeenCalledWith('hello', expect.any(Object));
  });
});

This pattern lets you test every registration path without starting dsh.