Agent Skillslichtblick-suite/lichtblick › test-conventions

test-conventions

GitHub

定义Lichtblick仓库中所有测试代理的共享约定,包括GWT模式、核心质量规则及标准测试编写工作流。

.github/skills/test-conventions/SKILL.md lichtblick-suite/lichtblick

Trigger Scenarios

需要编写单元测试或E2E测试 询问测试规范或最佳实践

Install

npx skills add lichtblick-suite/lichtblick --skill test-conventions -g -y
More Options

Non-standard path

npx skills add https://github.com/lichtblick-suite/lichtblick/tree/develop/.github/skills/test-conventions -g -y

Use without installing

npx skills use lichtblick-suite/lichtblick@test-conventions

指定 Agent (Claude Code)

npx skills add lichtblick-suite/lichtblick --skill test-conventions -a claude-code -g -y

安装 repo 全部 skill

npx skills add lichtblick-suite/lichtblick --all -g -y

预览 repo 内 skill

npx skills add lichtblick-suite/lichtblick --list

SKILL.md

Frontmatter
{
    "name": "test-conventions",
    "description": "Shared test conventions for all testing agents in the Lichtblick repo. Defines GWT pattern, core quality rules, and the standard test-writing workflow."
}

Test Conventions

Applies to all test agents (unit tests, E2E tests).


Given-When-Then (GWT)

Every test body must include GWT section comments.

Block-comment style (Desktop / E2E)

/**
 * GIVEN a .mcap file is loaded
 * WHEN play button is clicked
 * THEN playback time should advance
 */
test("should start playing when clicking on Play button", async ({ mainWindow }) => {
    // Given
    await loadFiles({ mainWindow, filenames: "example.mcap" });
    const button = mainWindow.getByTestId("play-button");

    // When
    await button.click();

    // Then
    await expect(button).toHaveAttribute("title", "Pause");
});

Inline comment style (Unit tests)

it("should return the layout when ID is valid", async () => {
    // Given
    const layout = LayoutBuilder.layout();
    // When
    const result = await service.findOne(layout.id);
    // Then
    expect(result).toEqual(layout);
});

Core Quality Rules

  1. One logical assertion per test — split complex scenarios into separate test() / it() blocks.
  2. Mock external dependencies, never business logic — mock file I/O, IPC, HTTP clients; test the real code under test.
  3. Use existing builders and fixtures — never create raw test data inline when a builder or fixture exists.
  4. Match sibling test structure exactly — same import style, same fixture usage, same GWT comment format as existing tests in the same directory.
  5. Run tests after writing — execute to verify they pass before presenting results.
  6. No any — use proper TypeScript types in all test code.
  7. Always read before writing — read the source file AND at least one existing sibling test file before generating new tests.

Test-Writing Workflow

  1. Read the source file — understand the component or feature under test.
  2. Read an existing sibling test — match the exact import style, fixture setup, and GWT comment format.
  3. Identify available builders / fixtures — check testing/builders/ (unit), e2e/fixtures/ (E2E), and e2e/page-objects/ (E2E).
  4. Write tests covering:
    • Happy path (valid input → expected outcome)
    • Edge cases (boundary values, empty state)
    • Error paths (invalid state → expected failure behavior)
  5. Run the tests to confirm they pass.
  6. Report which scenarios are covered and flag any missing edge cases.

Test Naming

TypeScript (Unit tests — Jest)

  • Describe blocks: describe('ComponentName')describe('methodOrBehavior')
  • Test titles: it('should <expected outcome> when <condition>')

TypeScript (E2E tests — Playwright)

  • Top-level test() with a descriptive title: "should <expected outcome> when <condition>"
  • Use a block-comment JSDoc above the test for the full GWT scenario description

Cleanup

Jest (unit tests)

afterEach(() => {
    jest.clearAllMocks();
    jest.restoreAllMocks();
});

Playwright (E2E)

  • Each test gets an isolated app/page via fixtures — no manual cleanup needed between tests
  • If a test opens a dialog or modifies shared state, restore it at the end of that test

Error Testing

Jest

await expect(service.create(dto)).rejects.toThrow(SomeException);

Playwright

await expect(page.getByRole("alert")).toBeVisible();
await expect(page.getByText("Error message")).toBeVisible();

Version History

  • cab9317 Current 2026-07-24 12:17

Same Skill Collection

.github/skills/3d-rendering/SKILL.md
.github/skills/caching-internals/SKILL.md
.github/skills/deserialization/SKILL.md
.github/skills/e2e-playwright-mcp/SKILL.md
.github/skills/electron-internals/SKILL.md
.github/skills/extensions-internals/SKILL.md
.github/skills/layouts-internals/SKILL.md
.github/skills/mcap-format/SKILL.md
.github/skills/message-path/SKILL.md
.github/skills/message-pipeline/SKILL.md
.github/skills/panel-extension-api/SKILL.md
.github/skills/panel-image/SKILL.md
.github/skills/panel-log/SKILL.md
.github/skills/panel-map/SKILL.md
.github/skills/panel-raw-messages/SKILL.md
.github/skills/panel-state-transitions/SKILL.md
.github/skills/panel-user-scripts/SKILL.md
.github/skills/performance/SKILL.md
.github/skills/player-internals/SKILL.md
.github/skills/plot-internals/SKILL.md
.github/skills/remote-caching/SKILL.md
.github/skills/theme/SKILL.md
.github/skills/unit-testing/SKILL.md
.github/skills/web-workers/SKILL.md
.github/skills/websocket-connection/SKILL.md

Metadata

Files
0
Version
cab9317
Hash
72eb10e8
Indexed
2026-07-24 12:17

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-08 03:41
浙ICP备14020137号-1 $bản đồ khách truy cập$