Type tests

From stefvw93/weft · View interactive version

Type tests is an AI agent skill from the GitHub repository stefvw93/weft. Step 3 of the Weft TDD workflow. Use after /mock: assesses whether the feature has meaningful type-level surface and, if so, writes __type-tests__/*.tst.ts TSTyche type tests with expect().type matchers. If not applicable, records an explicit skip in specs.md, never a silent skip.

How to use this skill

Skill file

/type-tests: TSTyche type tests (TDD step 3)

Verify the mocked type surface with TSTyche, or record an explicit, reasoned skip.

When to run

Procedure

  1. Assess applicability. Does the feature have meaningful type-level behavior worth locking down?

Trivial concrete signatures (already fully enforced by the main typecheck) do not warrant a type test.

  1. If not applicable: add to the feature's specs.md:

```markdown

type-tests: not applicable, <one-line reason>

```

Report the skip and reason to the user, then hand off to /unit-test.

  1. If applicable: write the test file at src/**/__type-tests__/<feature>.tst.ts in the owning package (discovery is governed by root tstyche.json testFileMatch). Each file is self-contained and tests one feature. Pattern:

```typescript

import { expect, test } from "tstyche";

test("descriptive name of the behavior", () => {

// Positive: exact type identity.

expect(someValue).type.toBe<SomeType>();

// Pure type-level comparison (no value involved).

expect<Derived<A>>().type.toBe<Expected>();

// Assignability when identity is not the intent.

expect(wider).type.toBeAssignableTo<Narrow>();

// Negative: rejected call (argument types/arity).

expect(fn).type.not.toBeCallableWith("bad", 123);

// Negative: property must not exist.

expect(obj).type.not.toHaveProperty("secret");

});

```

Cover:

Constraints: declare fixtures live at module scope (declare is illegal inside test() bodies). test() callbacks must not start comments with @ts-expect-error unless they are real directives. TSTyche parses them.

  1. Validate with vp run test:types (never bare tstyche/vp test: the pack rule; dom/router/website tests resolve @weftui/* through built dist/). The files also stay inside the tsc program (include: ["src"]), so vp run check still typechecks the test code itself. But only vp run test:types evaluates the assertions; a failed toBe is invisible to vp run check.
  1. Hand off. Next step is /unit-test.

Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.