close

rstestPlugin

rstestPlugin provides Rslint's rules for Rstest. Enable the recommended preset to catch common mistakes in test definitions, assertions, mocks, and snapshots.

Usage

Dedicated test files

For projects that keep tests in dedicated test and spec files, apply the preset to those files:

import { defineConfig, rstestPlugin } from '@rslint/core';

export default defineConfig([
  {
    ...rstestPlugin.configs.recommended,
    files: ['**/*.{test,spec}.{js,mjs,jsx,ts,tsx,mts}'],
  },
]);

In-source tests

When using Rstest's in-source testing, tests live alongside production code and access the test API through import.meta.rstest. Apply the preset to every linted file to check both dedicated test files and in-source tests:

import { defineConfig, rstestPlugin } from '@rslint/core';

export default defineConfig([rstestPlugin.configs.recommended]);

No additional Rslint globals are required for import.meta.rstest.

Rstack CLI projects

Projects driven by the Rstack CLI import the test API from rstack/test, which re-exports it. Every rule recognizes that specifier alongside @rstest/core, so the preset needs no extra configuration and a file may use either or both:

import { describe, expect, test } from 'rstack/test';

Configure test types separately

To use different rule settings for dedicated test files and in-source tests, create a configuration item for each group. Use files to match test and spec filenames in one item, and the source patterns from Rstest's includeSource configuration in the other.

Presets

PresetDescriptionView rules
rstestPlugin.configs.recommendedRstest rulesView rules →

See Rules & Presets for guidance on choosing and layering presets.