testing-patterns_skill

This skill guides you in writing and debugging unit and integration tests, mocking services, and testing Tryorama scenarios.
  • TypeScript

12

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill happenings-community/requests-and-offers --skill testing-patterns

  • SKILL.md5.4 KB

Overview

This skill provides concrete testing patterns for writing and debugging unit tests, integration tests, and mocks across Effect-TS services, Svelte 5 stores, and Holochain zomes. It collects practical examples, helper conventions, and common pitfalls to speed up reliable test development. Use it to standardize test structure and avoid subtle mismatches between Promise vs Effect interfaces.

How this skill works

The skill documents distinct patterns for three layers: service tests (mock Holochain client with Promise-based callZome), store tests (mock services that return Effect values), and Tryorama integration scenarios (multi-agent zome calls with explicit DHT sync and record decoding). It explains how to create test runners, provide dependency layers, and encode record entries for zome payloads. It also lists module-level mocking rules and hREA-specific module mocks required for successful test runs.

When to use it

  • Unit testing Effect-TS services that call zomes via a Holochain client
  • Testing Svelte 5 stores that expect Effect-returning service implementations
  • Setting up Tryorama multi-agent integration tests with DHT synchronization
  • Mocking zome records where entry bytes must be msgpack-encoded
  • Debugging failures caused by using Promises where Effects are required

Best practices

  • Mock Holochain client methods with Promise-returning functions (mockResolvedValue / mockRejectedValue) for service tests
  • Mock store dependencies to return Effect values (E.succeed / E.fail) when the store expects Effects
  • Encode zome record entries using @msgpack/msgpack encode() for all mock records
  • Perform module-level vi.mock() calls before importing stores that import other stores at module scope
  • In Tryorama scenarios always call dhtSync() between agent operations and decode results with decodeRecord(s)

Example use cases

  • Unit test a service create method by providing a mock Holochain client and asserting returned record from callZome
  • Unit test a Svelte store by injecting a mock service that returns E.succeed(mockRecord) and verifying store state
  • Run an integration test with two agents: get cells, call zomes, dhtSync between steps, and decode records
  • Create mock records for assertions by encoding entry payloads with @msgpack/msgpack in test helpers
  • Stub hREA and Apollo schema modules when running tests that depend on those libraries

FAQ

Service-level Holochain client mocks should return Promises (use mockResolvedValue). Services that are injected into stores should return Effects when the store expects Effects.

When must I encode record entries?

Always encode entry data with @msgpack/msgpack encode() for mock records used in zome payloads or assertions.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
testing-patterns skill by happenings-community/requests-and-offers | VeilStrat