Skip to content

docs: add Rust and TypeScript module unit testing guide - #6245

Open
clockwork-labs-bot wants to merge 1 commit into
masterfrom
docs/module-unit-testing
Open

clockwork-labs-bot wants to merge 1 commit into
masterfrom
docs/module-unit-testing

Conversation

@clockwork-labs-bot

Copy link
Copy Markdown
Contributor

Description of Changes

Add a unit-testing how-to for Rust and TypeScript modules, with links from both quickstarts and Developer Resources.

  • Explain the 2.12.0 minimum version, native Rust setup (test-utils), and Node/Vitest setup with spacetimedbModuleTestPlugin.
  • Provide runnable, language-appropriate message-module examples testing caller identity, deterministic timestamps, and transaction rollback.
  • Cover internal versus JWT-based test auth, fixture isolation, explicit lifecycle setup, deterministic RNG, and procedure/view/query contexts.
  • Show outbound HTTP mocks in both languages, including TypeScript response bodies and the Rust unstable feature requirement.
  • Distinguish module unit tests from integration tests against a running server.

Source references

API and ABI breaking changes

None. Documentation only.

Rollback safety impact

n/a

Expected complexity level and risk

  1. New guide and three navigation/cross-link updates; no product or test-runtime changes.

Testing

Examples are extracted directly from the guide and run in temporary, standalone projects using the published spacetimedb 2.12.0 packages, not repository-only imports.

  • TypeScript: all 3 extracted Vitest tests passed, including reading the mocked HTTP body.
  • TypeScript: strict tsc --noEmit passed for module, tests, and Vitest config.
  • pnpm --dir docs typecheck passed.
  • Full pnpm --dir docs build passed, including broken-link checks. It emitted the existing Browserslist age and ask-ai Markdown conversion warnings.
  • Rust: all 3 extracted tests passed with test-utils,unstable; the 2 reducer tests also passed with only test-utils.
  • Final pnpm --dir docs build passed again after the dependency-workaround note was added.
  • git diff --cached --check passed; TypeScript examples use camelCase.

Native Rust dependency finding

A clean lockfile against crates.io currently selects ICU 2.3, which fails while compiling the transitive temporal_rs 0.1.2 dependency (including a missing AnyCalendarDifferenceError). The repository lockfile uses ICU 2.1.1. Verified that pinning icu_calendar and icu_locale to =2.1.1 in dev-dependencies resolves the failure; the guide includes that narrowly scoped troubleshooting workaround. This is an upstream/runtime dependency issue, not a failure in the example module. No product dependency changes are included in this docs PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant