← 返回列表
全部 Skill›工具 Tools›write-insomnia-test

write-insomnia-test

作者 @Kong · 语言 en
Use when writing, adding, or modifying a Playwright E2E test case (tests/**/*.spec.ts) for the Insomnia desktop app in this repo. Converts a short plain-language scenario ("test that X happens when Y", "write a test that verifies...") into an accurate spec file built from the existing Model/Flow/Page/enum layers. Trigger whenever the user asks to add/write a test case, a happy-path, or an edge-case spec for any protocol (http/graphql/grpc/websocket/socket.io/event-stream/mcp-client), API Mock servers and routes (self-hosted), the Collection Runner, cookie, environment, import, export, template tags, git sync, cloud sync, plugins/script sandbox, organization/invite collaborators, legacy database migration, or preferences (vault key, cloud/vault-provider credentials), variable source (hover tooltip / tag-editor "Source" row), response export, and upgrade (old-version → current-version data) scenarios.
工具 Tools命令行工具通用访问网络待翻译
存储库
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
40,187
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Writing an Insomnia E2E Test Case

Core rule: reuse before you invent

This repo is strictly layered: tests/*.spec.ts → flows/*.flow.ts → pages/*.page.ts → models/*.ts. Writing a new test case almost never requires new Page/Flow/Model code — it's just composing existing methods in a spec file.

Before writing any code, scan the live framework (see step 3) and confirm, for the domain involved: the Flow's exact method signatures, the Model's exact fields, and the mock server URL to hit. This skill deliberately ships no static API reference — the source is the only source of truth. Do not call a method or pass a field from memory/guesswork — the single most common accuracy failure in this framework is inventing a Flow method or Model field that doesn't actually exist.

Framework facts the code doesn't make obvious

  • Fixtures: dataPath, skipOnboarding, vaultKey/vaultSalt are overridable via test.extend to seed state before launch. Git Sync specs import test (and the git helpers) from misc/git-fixtures, not misc/fixtures.
  • Single worker: the suite is serial (enforced in playwright.config.ts); module-level state in misc/git-fixtures.ts (currentGitRepo) and the mock servers' shared state depend on it.
  • Mock servers: started by playwright.config.ts's webServer, all loopback-only. Import base URLs from @package/misc/constants, never hardcode a port. TLS variants need preferencesFlow.set({ validateSSL: false }) unless the CA is added via certificatesFlow; mTLS also needs a client certificate. Toggles on the cloud API mock (_admin/* helpers in misc/fixtures.ts) must run before the app launches.
  • Timing: Page/Flow methods already wait for debounced saves to reach disk, so a spec never needs page.waitForTimeout(). For anything else use expect.poll / toPass with DEFAULT_TIMEOUT / ACTION_TIMEOUT / LONG_TIMEOUT from misc/constants.ts.
  • Timeouts inside a retry loop: the outer budget must be larger than the inner step timeouts. A toPass({ timeout: DEFAULT_TIMEOUT }) whose body does a bare click()/scrollIntoViewIfNeeded()/toBeHidden() with { timeout: DEFAULT_TIMEOUT } can burn the whole 10s on one attempt (e.g. a virtualized sidebar tree row unmounting mid-click on a slow CI runner), so the loop times out with zero retries. Fix it by giving the outer toPass a bigger existing constant (LONG_TIMEOUT) than the inner steps (DEFAULT_TIMEOUT), not by inventing a new number. Always take timeouts from misc/constants.ts (DEFAULT_TIMEOUT / ACTION_TIMEOUT / LONG_TIMEOUT / POLL_INTERVAL); only add a constant there when none of them fits.
  • Page/Flow layering: a Page exposes plain per-field setters and never takes a whole Model (except returning raw data from get()); the owning Flow holds the Model and dispatches to the setters.
  • Model construction: use a plain object literal when the constructor takes a single init object; new <Model>(...) only for positional-arg Models (e.g. Project, Collection, McpClient, Folder, MockServer).
  • No Flow ≠ no support: some domains have no dedicated Flow (e.g. Command Palette, Runner, Vault Key and Plugins live on workspaceFlow/preferencesFlow; Konnect and Login/Scratch Pad use a Page directly). Find them by scanning, not by assuming a <domain>Flow exists.
  • **Imports use the @package/* alias** (tsconfig.json paths), never relative ../../ paths — including from specs nested in a fixture directory, so depth never matters. Import order is lint-sorted (faker, then @package/... alphabetical, then @playwright/test).
  • Step reporting is explicit, not automatic: Flow methods opt in with the @step() decorator from misc/step.ts (Pages don't use it). A new Flow method that should appear as a report step needs @step(); specs never write test.step(...) themselves.
  • Coverage (COVERAGE=true) is CI-only; specs never need to know about it.

Prefer Flow methods over direct Page access

When a step can be done through a xxxFlow method, call that — never reach for the equivalent pageManager.xxxPage method just because it's more direct. A Flow method already sequences the right Page calls (and any related field the action implies — e.g. HttpRequestFlow.create() also applying auth/params/headers, not just the URL) in the order the app actually expects; composing a spec straight out of Page calls risks silently skipping or reordering a step the Flow would have handled correctly. This is also why a genuinely new spec almost always destructures a Flow instance first and a Page instance only if step 3 shows the action has no Flow wrapper — never the other way around.

Flow methods are explicit, not overloaded: each distinct action has its own named method (workspaceFlow.createProject() / .openLocalGitFolder() / .cloneGitProject() / .createCollection(), exportFlow.exportCollection() / .exportProject(), workspaceFlow.renameRequest() …) so a call site shows which flow

评论
KKong
Kong
Kong/insomnia
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@Kong
所属大类工具 Tools / 命令行工具
国内可用性通用
最近源活动—
风险提示访问网络
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。