Rstest Best Practices logo

Rstest Best Practices

Organization
rstackjs
rstest-best-practices

Set up, write, or review Rstest tests and configuration, including environments, mocks, snapshots, coverage, and CI.

Overview

Publisherrstackjs
Repositoryagent-skills
Skill namerstest-best-practices
Stars
93
Forks
4
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by rstackjs on GitHub. Read the source before you install it.

Installation

Install the Rstest Best Practices AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/rstackjs/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/rstest-best-practices .claude/skills/rstest-best-practices
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Rstest Best Practices in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Rstest Best Practices on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Rstest Best Practices is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Rstest best practices

Apply these rules when setting up, writing, or reviewing Rstest projects.

Workflow

  • Inspect the existing package manager, dependency policy, module mode, build configuration, test layout, and framework conventions before editing.
  • Add @rstest/core, a package-local test script, and a config file whose extension matches the package's module mode.
  • Reuse existing build configuration only when doing so lowers maintenance cost and remains compatible. An adapter is optional; use an independent Rstest config when adapter integration is incompatible or disproportionately costly, and explicitly reproduce required aliases, plugins, defines, environments, and externals.
  • Configure test discovery, environment, and setup files intentionally. Do not enable passWithNoTests unless an empty test set is an expected and documented state.
  • Verify test discovery with rstest list, then run focused tests, the full suite, and the project's existing build or type-check command.

Configuration and environments

  • Use defineConfig from @rstest/core and a config file extension compatible with the package's module mode.
  • Prefer explicit imports from @rstest/core over globals: true.
  • Use setupFiles for shared matchers and cleanup; use plugins, resolve, or source for ordinary build integration and low-level tools only when necessary.
  • Set include explicitly when the package's test layout is non-standard; do not assume the default discovery pattern.
  • Use node for server/SSR tests, happy-dom or jsdom for simulated DOM tests, and Browser Mode for real-browser behavior; install the selected environment package explicitly.
  • For React or Vue component tests, register the matching build plugin, use the corresponding Testing Library, and centralize matcher extension and cleanup in a setup file.
  • Use multiple test projects only when environments or configurations genuinely differ; keep global options such as reporters, coverage, pool, isolation, and bail at the root.

Test writing

  • Prefer small tests that verify one public behavior; use .skip or .todo intentionally and never commit .only.
  • Keep test APIs and test files in the same module system as the project; do not mix ESM/CJS assumptions without verifying the runtime and bundler behavior.
  • Prefer await expect(promise).resolves... and .rejects... over try/catch patterns that can miss assertions.
  • Use includeSource only for small utilities, guard tests with import.meta.rstest, and define it as false in production builds.

Mocking

  • Use rs.fn() for functions, rs.spyOn() for object methods, and rs.mock() factories for modules; mock external boundaries rather than the subject under test.
  • Choose clearMocks, resetMocks, or restoreMocks according to whether calls, implementations, or original methods must be restored between tests.
  • Choose the module-mocking API that matches the module system; verify the exact request string and register hoisted/static mocks before the module under test is evaluated.
  • Module mocks replace runtime behavior but do not necessarily remove the real dependency from the Rspack build graph. Use aliases or narrowly scoped externals only when the build still traverses an unwanted or unavailable dependency, and verify the runtime externalization format.

Snapshots and coverage

  • Keep snapshots small and deterministic: use inline snapshots for short output, file snapshots for large structured output, and serializers for paths or unstable data. Review every update.
  • Enable coverage with --coverage or coverage.enabled.
  • Choose a coverage provider supported by the installed Rstest version and add its package explicitly; do not copy a V8 or Istanbul provider choice without checking project needs.
  • Set coverage.include deliberately before adding thresholds; choose reporters for humans and CI artifacts separately.

Running and CI

  • Use rstest for a single run; rstest run is an optional explicit equivalent. Use rstest --watch or rstest watch only for local development.
  • Use rstest list to verify discovery, positional filters or -t for focused runs, -u for intentional snapshot updates, and -c for a non-default config.
  • In CI, never use watch mode. Use sharding with blob reports and rstest merge-reports when distributing tests; use JUnit when the CI system requires machine-readable results.
  • If passing-test logs are too noisy, consider silent: 'passed-only'; disable it temporarily when diagnosing setup or runtime output.

First-line debugging

  • Start with a focused repro and --reporter=verbose; use --printConsoleTrace for noisy or unclear console output.
  • Use DEBUG=rstest and inspect dist/.rstest-temp/.rsbuild/ to verify final Rstest/Rsbuild/Rspack configuration and generated build output.
  • Use breakpoints through the Rstest VS Code extension or a JavaScript Debug Terminal for runtime failures.
  • Use rstest-debugging for systematic startup, build, runtime, logging, memory, or performance diagnosis.

Documentation

Frequently asked questions

What does the Rstest Best Practices AI skill do?

Set up, write, or review Rstest tests and configuration, including environments, mocks, snapshots, coverage, and CI.

Why use Rstest Best Practices on TypingMind?

Because you install it once and use it with any model. Rstest Best Practices is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Rstest Best Practices in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/rstackjs/agent-skills/tree/main/skills/rstest-best-practices. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Rstest Best Practices?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Rstest Best Practices?

As many as you like. As long as a model supports skills, you can use Rstest Best Practices with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Rstest Best Practices AI skill free?

Yes. It is published on GitHub by rstackjs under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇