hoc-jest
Write Jest unit tests for JavaScript classes, and for the modules, data files and reconciliations a project tests alongside them. Use whenever a test is…
от openreachtech★ 17 звёзд на GitHub
Установить hoc-jest в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Jest Testing
A skill for writing Jest unit tests for JavaScript classes, and for the modules and data files a project tests alongside them. The conventions are split across the detail files below.
Five of them are read in full before the first line of a test is written, in a new test file or in one that already exists: naming.md, anti-pattern.md, structure.md, mocks.md and prohibit.md. They hold the prohibitions no lint rule catches, so a file written without them passes lint and passes its own tests while breaking this convention throughout, and nothing anywhere reports it. The rest are read as the work reaches them.
Measured: tests written with only the first three read carried a jest.fn() standing in for a
collaborator and a spy planted on a class prototype — both forbidden in the two files left
unread, and neither reported by lint.
Notation convention: Throughout this skill, when we simply write
describe()/test()/expect(), each is a generic term that implies the corresponding.each()variant (describe()includesdescribe.each(),test()includestest.each(), andexpect()includesexpect.each()). Where the context is limited to one or the other specifically, that will be stated explicitly.Also, use
test()/test.each()for test blocks and neverit()/it.each()(it()is easy to misread asif(); lint also enforcestestviajest/consistent-test-it; see eslint-jest-rules.md).
Core principle: don't cut coverage using implementation knowledge (QA stance)
Tests must be written so that they notice even if the implementation is wrong.
Using knowledge gained from reading the implementation to judge "this will always
be this value" or "this member is obvious" and then omitting cases or members,
or collapsing them into a single test(), is a QA mistake. What a test must
guarantee is not the implementation's internal circumstances, but the member's
contract (externally observable behavior) as a black box.
- Do not omit something because "the implementation is written this way so it's fine." If you do, hard-coding or regressions can slip in without the test noticing, which defeats the purpose of having a test at all.
- Example: for the instance getter
get Ctor () { return this.constructor }, collapsing it into a singletest()that says "in the base class it's alwaysBoundCtorRegistry" would still pass even for the hard-coded implementationreturn BoundCtorRegistry. Only by running the variable element (the instance's type) throughtest.each()can you verify the contract (structure.md). - Example: don't skip testing a static property because "the memoization pool is an implementation detail." Members that appear public should be verified as part of the contract.
- Example: for a member that transforms a property/argument before using it (escape / normalize / encode, etc.), don't test only with values for which the transformation is a no-op. Always include a value that actually exercises the transformation so that a broken transformation would be noticed (test-cases.md).
- When in doubt, err on the side of coverage. When trimming a member, branch, or variable element, the justification must be "this input/state cannot exist under the contract," never "because I know the implementation."
Run the test against the unchanged code first
A test written for a change is run against the code as it stands, before the change, and it has to fail there. A test that passes against the unchanged code is describing what the code already does — the one thing a test must not be, and the shape a test takes when it is written by reading the very implementation it is meant to check.
Measured on one such run: the new cases failed 19 and passed 8 against the unchanged code, and all 27 passed once the code had changed.
- The cases that pass against the unchanged code are the ones covering behaviour the change does not touch, and that is correct rather than a defect. In the run above the 8 were the surface that already existed, whose signature and behaviour the change left alone.
- So the run reports a split as well as a verdict: which of the new cases cover new ground, and which are holding ground that was already held.
Core principle: don't put logic in test files
A test must consist only of assertions (expect()) that check simple
input and output values. Writing logic inside a test to prepare it is a
well-known anti-pattern. Test code itself is not verified, so
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/aaa-pattern.md
- references/anti-pattern.md
- references/directory.md
- references/eslint-jest-rules.md
- references/mocks.md
- references/naming.md
- references/prohibit.md
- references/structure.md
- references/test-cases.md
- references/types.md
FAQ
Что делает скилл hoc-jest?
Write Jest unit tests for JavaScript classes, and for the modules, data files and reconciliations a project tests alongside them. Use whenever a test is created or updated — for a class, a module of exported constants, a data file such as a message catalogue, or a reconciliation between two collections that have to agree. Driving a failing suite to green belongs to the test-execution convention, and reusing a recorded pass over unchanged inputs to the test-cache convention.
Как установить скилл hoc-jest?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл hoc-jest запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…