Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

testing

БесплатноЗапускает вложенные скриптыНе проверен

Provides expertise on how to write effective unit tests (runtime and type tests), make testing decisions, and incorporate TDD into development workflows

inocan-groupот inocan-group★ 17 звёзд на GitHub6 установок в других каталогах

Об этом скилле

Testing Skill

Overview

This skill provides comprehensive guidance on testing in TypeScript projects, with a focus on the dual nature of testing: runtime behavior and type correctness. It covers when to use each type of test, how to structure tests effectively, and how to integrate testing into development workflows using Test-Driven Development (TDD).


Types of Testing

1. Runtime Tests

Runtime tests verify the actual behavior of code during execution.

When to use:

  • Testing function outputs with various inputs
  • Verifying error handling and edge cases
  • Checking side effects (file I/O, API calls, state mutations)
  • Validating business logic and algorithms
  • Testing class instance behavior and methods

Tools:

  • Test runner: Vitest
  • Commands:
    • pnpm test - runs all runtime tests
    • pnpm test GLOB - runs tests matching the glob pattern

Example structure:

import { describe, it, expect } from "vitest";
import { prettyPath } from "~/utils";

describe("prettyPath()", () => {
    it("should format a path with directory and filename", () => {
        const result = prettyPath("/path/to/file.ts");
        expect(result).toBe("/path/to/file.ts"); // Expected formatting
    });

    it("should handle edge case: empty string", () => {
        const result = prettyPath("");
        expect(result).toBe("");
    });

    it("should handle edge case: root path", () => {
        const result = prettyPath("/");
        expect(result).toBe("/");
    });
});

2. Type Tests

Type tests verify the type correctness of TypeScript code at design time.

When to use:

  • Testing type utility functions (always)
  • Verifying generic type constraints work as expected
  • Ensuring conditional types resolve correctly
  • Testing that complex inferred types are accurate
  • Validating discriminated unions and type narrowing
  • Checking that function signatures accept/reject correct types

Tools:

  • Commands:
    • pnpm test:types - runs all type tests
    • pnpm test:types GLOB - runs type tests matching the glob pattern

Type Test Structure

This section will show you, layer by layer, how to compose and build good type tests.

cases block

All type tests in a given it test block (defined by Vitest) will have a type called cases defined as an array of type tests.

type cases = [
    // ... type tests go here
]

Note: our linting rules allow for the name cases to be defined without being used; this is intentional and a good thing.

Expect<...> wrapper

Every type test will be wrapped by an Expect type utility.

type cases = [
    Expect<...>,
    Expect<...>,
    // ...
]
Available Type Test Assertions

The inferred-types library provides a number of useful assertion utilities you can use to create your tests:

  • AssertTrue<T> ****
    • tests whether the tested type T is the type true
  • AssertFalse<T>
    • tests whether the tested type T is the type false
  • AssertEqual<T,E>
    • tests that the tested type T equals the expected type E
  • AssertExtends<T,E>
    • tests that the tested type T extends the expected type E
  • AssertSameValues<T,E>
    • tests that the tested type T is an array type and every element of E and T are the same but the order in which they arrive does not matter
  • AssertContains<T,E>
    • when the tested type T is a string:
      • this utility will pass when E is also a string and represents a sub-string of the sting literal T
    • when the tested type T is an array then:
      • this utility

In all cases you put the test assertion inside of the Expect utility:

type cases [
    Expect<AssertTrue<T>>,
    Expect<AssertExtends<T, string>>,
    // ...
]
Example 1

In our example we'll just test a built-in type utility of Typescript's named Capitalize<T>.

  • this utility simply capitalizes the first letter in a string literal
import type { Expect, Equal } from "inferred-types/types";

describe("Example 1", () => {
    it("string literals", () => {
        type Lowercase = Capitalize<"foo">;
        type AlreadyCapitalized = Capitalize<"Foo">;

        type cases = [
            Expect<AssertEqual<Lowercase, "Foo">>,
            Expect<AssertEqual<AlreadyCapitalized, "Foo">>,
        ]
    });

    it("wide string", () => {
        type Wide = Capitalize<string>;

        type cases = [
            Expect<AssertEqual<Wide, string>>
        ]
    })

    it("only first letter capitalized", () => {
        type SpaceThenLetter = Capitalize<" foo">;
        type TabThenLetter = Capitalize<"\tfoo">;

        type cases = [
            Expect<AssertEqual<SpaceThenLetter, " foo">>,
            Expect<AssertEqual<TabThenLetter, "\tfoo">>,
        ]
    })
});

IMPORTANT: in the example above we were testing a type util

Полный SKILL.md на GitHub

Установить testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

scripts/start-position.ts

FAQ

Что делает скилл testing?

Provides expertise on how to write effective unit tests (runtime and type tests), make testing decisions, and incorporate TDD into development workflows

Как установить скилл testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл testing запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить testing с