Skip to main content

npm

Source

Description

Test utilities and fixtures for @wolfstar/http-framework — designed to work with Vitest.

Installation

Usage

createTestHarness

The entry point for most tests. Returns a TestableClient and an InteractionTestRunner wired together:

Running interactions

Use InteractionTestRunner.run() to dispatch a Discord interaction and get back a typed result:

Vitest custom matchers

Import and register the matchers in your Vitest setup file:
Then in tests:
toHaveJsonBody performs a strict deep-equality check: the expected object must contain the exact same set of keys as the response body at every level. If you only care about a subset of fields, assert against result.json() with Vitest’s built-in toMatchObject instead.

Available fixtures

Pre-built interaction payloads for all interaction types: Base data is also exported: UserData, InteractionGuildMemberData, MessageData, BaseInteractionData.

Helper utilities

Exports

Requirements

  • Node.js >=20
  • @wolfstar/http-framework (peer dependency)
  • vitest >=4.0.0 (optional peer dependency — only needed for the /vitest entry point)