Logo Hor Backend Testing

Hor Backend Testing

Tổ chức
openreachtech
hor-backend-testing

Organize and run the backend repository's tests: where a test file goes (tests/__tests__ for tests that do not write to the database, tests/_orders for tests that do), how run order among DB-writing tests is guaranteed, how to run the whole suite or a single test, and the purity rules for tests and their doubles. Use whenever the user asks where to place a test, how to guarantee test order, how to run tests, or how to keep tests pure. Manual E2E verification is out of scope.

Tổng quan

Nhà phát hànhopenreachtech
Kho mãhora-skills-ort-renchan
Tên kỹ nănghor-backend-testing
Sao
32
Bản fork
0
Tệp đi kèm
3
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 3 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được openreachtech công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Hor Backend Testing trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-backend-testing
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openreachtech/hora-skills-ort-renchan.git /tmp/hora-skills-ort-renchan
mkdir -p .claude/skills
cp -r /tmp/hora-skills-ort-renchan/kit/skills/hor-backend-testing .claude/skills/hor-backend-testing
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Hor Backend Testing trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Hor Backend Testing ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Hor Backend Testing không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Backend Testing

A skill for implementing tests in a backend repository: where each test file belongs, how DB-writing tests are ordered so they do not corrupt each other, how to run them, and the purity rules that keep a failing test meaningful. It governs test organization and discipline — the writing style of an individual test (describe/test structure, case data, naming) follows the project's own Jest conventions and is out of scope here.

This skill states a general, project-independent rule, not one repo's current tree. The directory names (tests/__tests__, tests/_orders, tests/mocks, tests/tools) are the recommended layout — map them onto your project. Sample code follows the project's lint style (no semicolons, 2-space indent, trailing commas).

Core principle: a test fails only when the code under test is wrong

A test must fail only because the code it exercises is wrong — not because another test ran first, and not because the test itself contains untested logic. Two rules enforce that, and everything below follows from them:

  1. Isolate database state. A test that writes to the DB mutates shared seed data that other tests read, so it is placed apart from tests that don't, and ordered among its peers.
  2. Keep tests pure. A test may only exercise code that is itself already tested — no logic is invented inside a test, and every mock/tool it leans on has its own test cases.

1. Placement & execution order

Split every test by one question: does it write to the database?

LocationContentsOrdering
tests/__tests__/tests that do not write to the DB (pure units, read-only)order-independent — run in any order
tests/_orders/<Category>/tests that do write to the DBorder-guaranteed within a category via a _.test.js barrel
  • Why the split. A DB-writing test changes the shared development / dev-master seed fixtures, so a later test can observe a mutated database. Read-only tests can't interfere, so they need no ordering; DB-writing tests must be ordered.
  • The order barrel. Each category folder holds _.test.js that imports its test files in the order they must run — that import order is the execution order within the category.
  • Cross-category order is NOT guaranteed. _orders fixes order within a category only. If two categories can interfere, isolate them into separate CI jobs — add/update a .github/workflows/*.yml per category so each runs against its own fresh database.
  • Verification against real middleware belongs in neither location. Exercising the product against a real broker, search cluster and change-data-capture pipeline needs those services brought up in Docker and is done by hand, outside tests/ entirely — see the E2E environment convention. No such file is added here, and npm run test stays runnable with nothing but Node installed.

Details, the barrel example, and the per-category workflow snippet are in placement-and-ordering.md.

2. Running tests

  • Whole suite: npm run test — rebuilds the DB (teardown → migrate → seed) and runs everything on SQLite (the local default). Authoritative, slowest.
  • A single test (fast, no rebuild): iterate by invoking Jest directly against one file — NODE_OPTIONS="--experimental-vm-modules" NODE_ENV=development npx jest <path> (add --runInBand for DB-writing/order-sensitive tests). It runs against the DB as it currently is, so prepare the DB once and reset it piecemeal (migrations-only / one-seeder-set) instead of a full rebuild.
  • Live (real-dialect) run: running against the database the project's specification names (MariaDB, MySQL or PostgreSQL) instead of SQLite requires that database running locally, selected with NODE_ENV=live. Test against the one the specification names, never another database of the same family. How that database is stood up is not part of this convention.
  • Parallelism × per-worker heap must fit in real memory. Jest runs one worker per core by default, and --max-old-space-size is not a reservation — it is how far the GC may be deferred, so a value the machine cannot actually give lets every worker grow until it crashes the machine (one worker alone can do it). Derive the cap from a measured peak, check that workers × cap fits in the memory actually free, and re-check as the project grows: per-worker usage rises with every model and seeder added, so a pair that fit at the start can later crash the machine.

The exact commands, the suite runner's steps, the fast single-test loop with the piecemeal DB reset, and how to size the worker/heap budget are in running-tests.md.

3. Test purity & test doubles

  • No new logic in a test. Never define a function or class inside a test to compute an expected value or stand in for production behavior — an untested helper can be wrong, making the test lie. Assert against literal expectations.
  • Everything a test uses must already be tested. Every function, class, mock, and tool the test leans on has its own test cases.
  • Doubles live under tests/, and are themselves tested. Mocks go in tests/mocks/, shared test tools/factories in tests/tools/, and each mock class has its own test file. Prefer explicit fakes (obviously-fake names/values).

The rule with good/avoid examples, and the mocks/tools layout, are in purity-and-mocks.md.

Finishing checklist

  • The test is in tests/__tests__/ if it does no DB write, or tests/_orders/<Category>/ if it does (§1).
  • A DB-writing test is imported (in the right position) by its category's _.test.js barrel.
  • If the new test's category can interfere with another, a per-category CI workflow isolates them.
  • The test defines no new logic; every function/class/mock it uses is already tested (§3).
  • Any new mock/tool lives under tests/mocks/ or tests/tools/ and has its own test file.
  • Verified with a single-test run (§2).

Detail files

  • placement-and-ordering.md — __tests__ vs _orders, why DB-writing tests need ordering, the _.test.js order barrel, cross-category isolation via per-category CI workflows (§1)
  • running-tests.md — the whole-suite runner and what it does, running a single test with the dev/master seed sets, resetting the database piecemeal, sizing the parallelism × heap budget against real memory, and what a live (real-dialect) run requires (§2)
  • purity-and-mocks.md — no-new-logic and only-tested-code rules with good/avoid examples, and the tests/mocks / tests/tools layout where doubles are themselves tested (§3)

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Hor Backend Testing làm được gì?

Organize and run the backend repository's tests: where a test file goes (tests/__tests__ for tests that do not write to the database, tests/_orders for tests that do), how run order among DB-writing tests is guaranteed, how to run the whole suite or a single test, and the purity rules for tests and their doubles. Use whenever the user asks where to place a test, how to guarantee test order, how to run tests, or how to keep tests pure. Manual E2E verification is out of scope.

Vì sao nên dùng Hor Backend Testing trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Hor Backend Testing là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Hor Backend Testing trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-backend-testing. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Hor Backend Testing?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Hor Backend Testing với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Hor Backend Testing với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Hor Backend Testing có miễn phí không?

Có. Kỹ năng này được openreachtech phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇