test-jest-imports
What a test file imports from Jest.
Agent checkAdvises by default
The rule
Agents read this text as written when they write and review code.
Import the test functions by name from @jest/globals, as the file's first import: import { describe, expect, test } from '@jest/globals';. Add jest only when the file uses jest.fn, jest.mock or jest.spyOn, and beforeEach, afterEach or afterAll only when the file needs one.
Examples
The agent flags code like the incorrect example and accepts code like the correct one. Each example is a small repo, because this rule looks across files. It opens on the file that matters; the other files are the repo around it.
Incorrect
srcbilling
interface Params {value: number;}export const formatRate = ({ value }: Params): string => `${value * 100}%`;
Correct
srcbilling
interface Params {value: number;}export const formatRate = ({ value }: Params): string => `${value * 100}%`;
Configure
- Block
"blocking"Stops a run when a file the run changed breaks the rule. - AdviseDefault
"advisory"Reports it and hands it to the refactor agent. Never stops a run. - Off
"off"Not checked. Use it when your own linter already enforces the rule.
Add this to your lightsout.config.json, then change the value.
{"standards-rule-settings": {"test-jest-imports": "advisory"}}