For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/rstest/no-mocks-import.md.
close

no-mocks-import

Added in v0.7.2

Configuration

PresetConfigured Value
✅ rstestPlugin.configs.all"warn"
✅ rstestPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, rstestPlugin } from '@rslint/core';

export default defineConfig([
  rstestPlugin.configs.recommended,
  {
    rules: {
      'rstest/no-mocks-import': 'error',
    },
  },
]);

Rule Details

Disallows importing a manual mock directly from a __mocks__ directory. Tests should mock the original module path so Rstest controls which module instance is used.

The rule checks both import declarations and require() calls.

Incorrect

import userClient from './__mocks__/user-client';

Correct

rs.mock('./user-client');
import userClient from './user-client';