Token导航 LogoToken导航

Agent Skill · 研究检索

twd-test-writer(TWD 测试编写器)

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

twd-test-writer 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 52,043。

总安装 564周安装 24GitHub Stars 35下载 198核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:twd-test-writer(TWD 测试编写器)
来源仓库:https://github.com/brikev/twd
仓库路径:skills/twd-test-writer
安装命令:
npx skills add https://github.com/brikev/twd --skill twd-test-writer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/brikev/twd --skill twd-test-writer

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。适用于需要提升测试覆盖率和质量的研发场景。

支持主流 AI 编程工具集成使用。

来源仓库内路径:skills/twd-test-writer

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/brikev/twd --skill twd-test-writer;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

twd-test-writer 怎么安装?

在终端执行 npx skills add https://github.com/brikev/twd --skill twd-test-writer。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

twd-test-writer 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

twd-test-writer 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

twd-test-writer 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

twd-test-writer 用的人多吗?

公开数据是累计安装 564 次,近一周安装 24 次,下载 198 次,GitHub 35 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

twd-test-writer 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
twd-test-writer

TWD 测试编写器 · 本页

56435操作浏览器未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

TWD Test Writing Guide

You are writing tests for TWD (Test While Developing), an in-browser testing library. Tests run in the browser (not Node.js) with a sidebar UI for instant visual feedback. Syntax is similar to Jest/Cypress but with key differences.

Key characteristics:

  • Designed for SPAs (React, Vue, Angular, Solid.js)
  • Not suitable for SSR-first architectures (Next.js App Router)
  • Uses Mock Service Worker (MSW) for API mocking
  • Uses @testing-library/dom for element queries

Testing Philosophy: Flow-Based Tests

TWD tests should focus on full user flows, not granular unit-style assertions. Each it() block should test a meaningful user journey through a page — load, interact, verify — rather than isolating individual elements.

Why flow-based?

  • TWD runs in the browser with full rendering — leverage that to test real user behavior
  • Flow tests catch integration issues (data loading → rendering → interaction → submission)
  • Fewer, richer tests are more maintainable than dozens of shallow ones

DO — test a full flow per it() block:

it("should allow user to search and view results", async () => {
  await twd.mockRequest("getUsers", { method: "GET", url: "/api/users", response: mockUsers, status: 200 });
  await twd.visit("/users");
  await twd.waitForRequest("getUsers");

  // Verify page loaded
  twd.should(screenDom.getByRole("heading", { name: "Users" }), "be.visible");
  expect(screenDom.getAllByRole("row")).to.have.length(mockUsers.length + 1); // +1 for header

  // Search interaction
  const user = userEvent.setup();
  await user.type(screenDom.getByLabelText("Search"), "John");
  await user.click(screenDom.getByRole("button", { name: "Search" }));
  await twd.waitForRequest("searchUsers");

  // Verify filtered results
  expect(screenDom.getAllByRole("row")).to.have.length(2);
  twd.should(screenDom.getByText("John Doe"), "be.visible");
});

DON'T — write one tiny test per element:

// BAD: too granular, doesn't test real user behavior
it("should render heading", async () => { /* only checks heading */ });
it("should render search input", async () => { /* only checks input exists */ });
it("should render table", async () => { /* only checks table exists */ });
it("should render first row", async () => { /* only checks one row */ });

Guidelines:

  • One describe() per page or major feature
  • Each it() covers a complete flow: setup → navigate → interact → assert outcome
  • Group related flows: happy path, error states, empty states, CRUD operations
  • It's fine for an it() block to have multiple assertions — they should tell a story
  • Avoid testing implementation details; test what the user sees and does

Required Imports

Every TWD test file needs these exact imports:

import { twd, userEvent, screenDom, expect } from "twd-js";
import { describe, it, beforeEach, afterEach } from "twd-js/runner";

Package exports:

  • twd-js — Main API (twd, userEvent, screenDom, screenDomGlobal, expect)
  • twd-js/runner — Test functions (describe, it, beforeEach, afterEach)
  • twd-js/ui — UI components (MockedComponent)

NEVER import describe, it, beforeEach from Jest, Mocha, or other libraries. They MUST come from twd-js/runner. expect MUST come from twd-js.

File Location and Naming

Place all test files in src/twd-tests/. For larger projects, organize by domain:

src/twd-tests/
  app.twd.test.ts
  auth/
    login.twd.test.ts
    register.twd.test.ts
  dashboard/
    overview.twd.test.ts
  mocks/
    users.ts

Test files must follow: *.twd.test.ts or *.twd.test.tsx.

When to use .tsx: If your test uses twd.mockComponent() with JSX in the mock implementation, the file must use the .tsx extension. Use .ts for tests that don't contain JSX. When using .tsx test files, ensure the entry point glob pattern includes them: import.meta.glob("./**/*.twd.test.{ts,tsx}").

Core Rules

Async/Await is Required

// twd.get() and twd.getAll() are async — ALWAYS await
const button = await twd.get("button");
const items = await twd.getAll(".item");

// userEvent methods are async — ALWAYS await
await userEvent.click(button.el);
await userEvent.type(input, "text");

// Test functions should be async
it("should do something", async () => { /* ... */ });

Element Selection

Preferred: Testing Library queries via screenDom

// By role (most accessible — RECOMMENDED)
const button = screenDom.getByRole("button", { name: "Submit" });
const heading = screenDom.getByRole("heading", { name: "Welcome", level: 1 });

// By label (for form inputs)
const emailInput = screenDom.getByLabelText("Email Address");

// By text content
const message = screenDom.getByText("Success!");
const partial = screenDom.getByText(/welcome/i);

// By test ID
const card = screenDom.getByTestId("user-card");

// Query variants
screenDom.getByRole("button");        // Throws if not found
screenDom.queryByRole("button");      // Returns null if not found
await screenDom.findByRole("button"); // Waits for element (async)
screenDom.getAllByRole("button");     // Returns array

For modals/portals use screenDomGlobal:

import { screenDomGlobal } from "twd-js";
const modal = screenDomGlobal.getByRole("dialog");

Fallback: CSS selectors via twd.get()

const button = await twd.get("button");
const byId = await twd.get("#email");
const byClass = await twd.get(".error-message");
const multiple = await twd.getAll(".item");

User Interactions

const user = userEvent.setup();

// With screenDom elements (direct)
await user.click(screenDom.getByRole("button", { name: "Save" }));
await user.type(screenDom.getByLabelText("Email"), "hello@example.com");

// With twd.get() elements (use .el for raw DOM)
const twdButton = await twd.get(".save-btn");
await user.click(twdButton.el);

// Other interactions
await user.dblClick(element);
await user.clear(input);
await user.selectOptions(select, "option-value");
await user.keyboard("{Enter}");

Assertions

Method style (on twd elements):

const element = await twd.get("h1");
element.should("have.text", "Welcome");
element.should("contain.text", "come");
element.should("be.visible");
element.should("not.be.visible");
element.should("have.class", "header");
element.should("have.value", "test@example.com");
element.should("have.attr", "type", "submit");
element.should("be.disabled");
element.should("be.enabled");
element.should("be.checked");
element.should("be.focused");
element.should("be.empty");

Function style (any element):

twd.should(screenDom.getByRole("button"), "be.visible");
twd.should(screenDom.getByRole("button"), "have.text", "Submit");

URL assertions:

await twd.url().should("eq", "http://localhost:3000/dashboard");
await twd.url().should("contain.url", "/dashboard");

Chai expect (for non-element assertions):

expect(array).to.have.length(3);
expect(value).to.equal("expected");
expect(obj).to.deep.equal({ key: "value" });

Navigation and Waiting

await twd.visit("/");
await twd.visit("/login");
await twd.wait(1000); // Wait for time (ms)
await screenDom.findByText("Success!"); // Wait for element
await twd.notExists(".loading-spinner"); // Wait for element to NOT exist

API Mocking

TWD uses Mock Service Worker. Always mock BEFORE the request fires.

// Mock GET request
await twd.mockRequest("getUser", {
  method: "GET",
  url: "/api/user/123",
  response: { id: 123, name: "John Doe" },
  status: 200,
});

// Mock POST request
await twd.mockRequest("createUser", {
  method: "POST",
  url: "/api/users",
  response: { id: 456, created: true },
  status: 201,
});

// URL patterns with regex
await twd.mockRequest("getUserById", {
  method: "GET",
  url: /\/api\/users\/\d+/,
  response: { id: 999, name: "Dynamic User" },
  urlRegex: true,
});

// Error responses
await twd.mockRequest("serverError", {
  method: "GET",
  url: "/api/data",
  response: { error: "Server error" },
  status: 500,
});

// Wait for request and inspect body
const rule = await twd.waitForRequest("submitForm");
expect(rule.request).to.deep.equal({ email: "test@example.com" });

// Wait for multiple requests
await twd.waitForRequests(["getUser", "getPosts"]);

Component Mocking

// In your component — wrap with MockedComponent
import { MockedComponent } from "twd-js/ui";

function Dashboard() {
  return (
    <MockedComponent name="ExpensiveChart">
      <ExpensiveChart data={data} />
    </MockedComponent>
  );
}
// In your test
twd.mockComponent("ExpensiveChart", () => (
  <div data-testid="mock-chart">Mocked Chart</div>
));

Module Stubbing with Sinon

Tests run in the browser. ESM named exports are IMMUTABLE and cannot be stubbed.

Solution: wrap hooks/services in objects with default export.

// hooks/useAuth.ts — CORRECT: stubbable
const useAuth = () => useAuth0();
export default { useAuth };

// hooks/useAuth.ts — WRONG: cannot be stubbed
export const useAuth = () => useAuth0();
// In test:
import Sinon from "sinon";
import authModule from "../hooks/useAuth";

Sinon.stub(authModule, "useAuth").returns({
  isAuthenticated: true,
  user: { name: "John" },
});
// Always Sinon.restore() in beforeEach

Standard Test Template

import { twd, userEvent, screenDom, expect } from "twd-js";
import { describe, it, beforeEach } from "twd-js/runner";

// Mock data — define at the top for reuse across tests
const mockItems = [
  { id: 1, name: "Item One", status: "active" },
  { id: 2, name: "Item Two", status: "draft" },
];

describe("Items Page", () => {
  beforeEach(() => {
    twd.clearRequestMockRules();
    twd.clearComponentMocks();
  });

  it("should load and display items, then filter by status", async () => {
    // 1. Setup mocks BEFORE visiting
    await twd.mockRequest("getItems", {
      method: "GET",
      url: "/api/items",
      response: mockItems,
      status: 200,
    });

    // 2. Navigate and wait for data
    await twd.visit("/items");
    await twd.waitForRequest("getItems");

    // 3. Verify page loaded correctly
    twd.should(screenDom.getByRole("heading", { name: "Items" }), "be.visible");
    expect(screenDom.getAllByRole("listitem")).to.have.length(2);

    // 4. Interact — filter by status
    const user = userEvent.setup();
    await user.selectOptions(screenDom.getByLabelText("Status"), "active");

    // 5. Assert filtered result
    expect(screenDom.getAllByRole("listitem")).to.have.length(1);
    twd.should(screenDom.getByText("Item One"), "be.visible");
  });

  it("should create a new item via the form", async () => {
    await twd.mockRequest("getItems", {
      method: "GET",
      url: "/api/items",
      response: mockItems,
      status: 200,
    });
    await twd.mockRequest("createItem", {
      method: "POST",
      url: "/api/items",
      response: { id: 3, name: "New Item", status: "draft" },
      status: 201,
    });

    await twd.visit("/items");
    await twd.waitForRequest("getItems");

    // Fill and submit the form
    const user = userEvent.setup();
    await user.type(screenDom.getByLabelText("Name"), "New Item");
    await user.selectOptions(screenDom.getByLabelText("Status"), "draft");
    await user.click(screenDom.getByRole("button", { name: "Create" }));

    // Verify the request payload and success state
    const req = await twd.waitForRequest("createItem");
    expect(req.request).to.deep.equal({ name: "New Item", status: "draft" });
    twd.should(await screenDom.findByText("Item created successfully"), "be.visible");
  });

  it("should show empty state when no items exist", async () => {
    await twd.mockRequest("getItems", {
      method: "GET",
      url: "/api/items",
      response: [],
      status: 200,
    });

    await twd.visit("/items");
    await twd.waitForRequest("getItems");

    twd.should(screenDom.getByText(/no items found/i), "be.visible");
    twd.should(screenDom.getByRole("button", { name: "Create" }), "be.visible");
  });

  it("should handle server error gracefully", async () => {
    await twd.mockRequest("getItems", {
      method: "GET",
      url: "/api/items",
      response: { error: "Internal server error" },
      status: 500,
    });

    await twd.visit("/items");
    await twd.waitForRequest("getItems");

    twd.should(await screenDom.findByText(/something went wrong/i), "be.visible");
  });

  it.only("debug this test", async () => { /* Only this test runs */ });
  it.skip("skip this test", async () => { /* This test won't run */ });
});

Common Mistakes to AVOID

  1. Forgetting await on twd.get(), userEvent.*, twd.visit(), screenDom.findBy*
  2. Mocking AFTER visit — always mock before twd.visit() or the action triggering the request
  3. Not clearing mocks — always twd.clearRequestMockRules() and twd.clearComponentMocks() in beforeEach
  4. Using Node.js APIs — tests run in the browser, no fs, path, etc.
  5. Importing from wrong package — describe/it/beforeEach from twd-js/runner, expect from twd-js, NOT Jest/Mocha
  6. Using Cypress syntax — no cy.get(), cy.visit(). Use twd.get(), twd.visit()
  7. Stubbing named exports — ESM makes them immutable. Use the default-export object pattern
  8. Using global describe/it — always import from twd-js/runner

平台分布

Codex

36.36%
按下载量换算72

Claude

30.69%
按下载量换算61

Cursor

18.02%
按下载量换算36

Gemini CLI

9.71%
按下载量换算19

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills