Skip to content
Data
Skill

/walkeros-testing-strategy

walkerOS uses a layered testing approach with built-in patterns for mocking and documentation sync. This skill ensures tests are reliable, efficient, and maintainable.

From plugin
walkeros
35122 skills

Claude Code

$ npx -y skills add elbwalker/walkerOS --skill walkeros-testing-strategy --agent claude-code

SKILL.md

walkeros-testing-strategy.SKILL.md
name: walkeros-testing-strategy
description:
  Use when writing tests, reviewing test code, or discussing testing approach
  for walkerOS packages. Covers env pattern, dev examples, and package-specific
  strategies.

walkerOS Testing Strategy

Overview

walkerOS uses a layered testing approach with built-in patterns for mocking and documentation sync. This skill ensures tests are reliable, efficient, and maintainable.

**Core principle:** Test real behavior using the `env` pattern, link to `dev` examples, verify before claiming complete.

The Rules

Rule 1: Use `env` for Mocking, Not Jest

walkerOS has a built-in dependency injection pattern via `env` in context. This is lighter than Jest mocks, enables documentation generation, and keeps tests in sync with examples.

**Wrong:**

jest.mock('../ga4', () => ({ initGA4: jest.fn() }));
expect(initGA4).toHaveBeenCalledWith(...);

**Right:**

import { examples } from '../dev';
import { mockEnv } from '@walkeros/core';

const calls: Array<{ path: string[]; args: unknown[] }> = [];
const testEnv = mockEnv(examples.env.push, (path, args) => {
  calls.push({ path, args });
});

await destination.push(event, { ...context, env: testEnv });
expect(calls).toContainEqual({
  path: ['window', 'gtag'],
  args: ['event', 'page_view', { page_title: 'Home' }],
});

Rule 2: Link Tests to `dev` Examples

The `dev.ts` export provides `examples.env` (the mock env and its `simulation` paths) and `examples.step` (the step examples), plus `examples.minimal` for a destination and `examples.createTrigger` for a source. Using these in tests ensures documentation stays in sync.

Step Examples on a Real Collector

A destination's step examples run through `runExamples`, which starts a real collector for each one and compares its `out` and `outcome`:

import type { StandardEventName } from '@walkeros/core';
import { runExamples } from '@walkeros/collector/dev';
import { page } from '@walkeros/web-core/dev';
import { destinationMeta } from '..';
import { examples } from '../dev';

// The standard events the destination maps, each with a public example
const claims: StandardEventName[] = [
  'page view',
  'product view',
  'product add',
  'order complete',
];

// The init example takes a config as `in`, not an event
const { init, ...events } = examples.step;

it('runs the step examples', async () => {
  await runExamples('destination', destinationMeta, events, {
    settings: examples.minimal.settings,
    env: { push: examples.env.push, simulation: examples.env.simulation },
    page,
    claims,
  });
});

(`packages/web/destinations/meta/src/__tests__/conformance.test.ts` runs this test.)

A source's step examples run one test per example with `it.each(Object.entries(examples.step))`: the test feeds each example's `trigger` and `in` through `examples.createTrigger` and compares what the source hands the collector with `out` (see `packages/server/sources/express/src/__tests__/stepExamples.test.ts`).

See [using-step-examples](../walkeros-using-step-examples/SKILL.md) for the full lifecycle including the Three Type Zones and naming conventions.

Rule 3: Test Real Behavior, Not Mock Behavior

If you're asserting that a mock was called, you're testing the mock works, not the code.

**Red flags:**

  • `expect(mockFn).toHaveBeenCalled()` without verifying the mock produces real

effects

  • Assertions on `*-mock` test IDs
  • Tests that pass when mock is present, fail when removed

**Fix:** Test what the code actually does. If external APIs must be mocked, verify the real API would receive correct data.

Rule 3b: Prove Delivery, Loss and Failures on a Real Collector

A test or repro that claims an event was delivered, lost or reported as failed starts a real collector with `startFlow` and mocks only the network or the vendor global (through `env`), never `collector.push`. A suite that mocks the collector cannot see loss: a destination that returns early, swallows an error or forgets an `await` passes it. Assert on what a user sees at default settings: the push result (`ok: false`, the destination under `failed` with its `reason`), the status counters, or the ERROR line the collector wrote.

Failure paths are examples too. A step package's failure modes (a missing required setting, a failing transport, a vendor script that is not loaded yet) are `public: false` step examples with an `outcome` (and `respond` for a vendor answer), not only the happy path. A `silent` rule and a consent revocation get examples as well.

**Use the conformance kit.** `conformance(kind, step, options)` from `@walkeros/collector/dev` runs a destination, source, transformer or store on a real collector against its step examples and checks the failure contract in one call. The `profile` states what the step talks to: for destinations `http`, `sdk-env`, `web-sdk` (a web SDK started in `init`), `vendor-global` or `socket`; `transformer` and `source` for those kinds. A web step passes `page` from `@walkeros/web-core/dev`, the browser it runs on; the browser profiles fail without it. A destination also passes `minimal: examples.minimal` (from `src/examples/minimal.ts`, only the settings the schema requires or `init` refuses to start without): the kit starts the destination with the settings its docs quickstart shows and requires one public example delivered. A package that cannot have a minimal example passes `withoutMinimal: '<reason>'` instead; with neither, or with an option that disagrees with the file, the test fails. `runExamples` runs the examples alone.

**Examples are the tests.** A destination's public examples (one per standard event it maps, from `getEvent(name)`) are asserted by `runExamples` with `claims`; do not restate an example's input and assertion in a second test. Every example runs as published: each function as source text, revived outside its module, the way `walkerOS.json` ships it (the runner

Read more
@elbwalker
Ships withwalkeros

From browser to BigQuery and ad platforms - warehouse-native, and ready for AI agents via MCP.

Stars on GitHub

Momentum

stars in total
351
Star history of elbwalker/walkerOS on GitHub, a chart by star-history.com

Other skills on walkeros.

walkeros-create-source

walkeros-create-source

Use when creating a new walkerOS source to capture events (browser source, dataLayer interception, server/HTTP source, webhook…

@elbwalker@elbwalkerInstall Skill

More skills from other plugins.

paddleocr-doc-parsing

paddleocr-doc-parsing

Use this skill to extract structured Markdown/JSON from PDFs and document images—tables with cell-level precision, formulas as…

paddleocr2mo93k
@paddlepaddle@paddlepaddleInstall Skill
context-loader
Auto-invoked

context-loader

Search memories from earlier Pi sessions in this repository. Use it when earlier work may already explain the code, error,…

mem02w69k
@mem0ai@mem0aiInstall Skill
analyzing-ai-citations

analyzing-ai-citations

Answer AI citation and answer engine optimization (AEO) questions in PostHog: whether AI answer engines (ChatGPT, Claude, and an…

posthog3w41k
@posthog@posthogInstall Skill

Questions about walkeros-testing-strategy.

Which coding agents can use walkeros-testing-strategy?
walkeros-testing-strategy installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.