{"record":{"id":"3bdd8c932a88c27d","repo":"oxc-project/oxc","slug":"enforces-a-maximum-number-assertion-calls-in-a-tes","errorCode":null,"errorMessage":"Enforces a maximum number assertion calls in a test body.","messagePattern":"Enforces a maximum number assertion calls in a test body\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/max_expects.rs","lineNumber":15,"sourceCode":"use rustc_hash::FxHashMap;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse oxc_ast::{AstKind, ast::Expression};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_span::Span;\n\nuse crate::{\n    context::LintContext,\n    utils::{PossibleJestNode, collect_possible_jest_call_node},\n};\n\nfn exceeded_max_assertion(count: u32, max: u32, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Enforces a maximum number assertion calls in a test body.\")\n        .with_help(format!(\"Too many assertion calls ({count}) - maximum allowed is {max}\"))\n        .with_label(span)\n}\n\npub const DOCUMENTATION: &str = r\"### What it does\n\nThis rule enforces a maximum number of `expect()` calls in a single test.\n\n### Why is this bad?\n\nTests with many different assertions are likely mixing multiple objectives.\nIt is generally better to have a single objective per test to ensure that when a test fails,\nthe problem is easy to identify.\n\n### Examples\n\nExamples of **incorrect** code for this rule:\n```javascript","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/max_expects.rs#L1-L33","documentation":"Raised by jest/max-expects when the number of assertion calls (expect(...)) in a single test body exceeds the configured maximum (default 5). Large assertion counts usually signal a test doing too much.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/max_expects.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Split the test into smaller focused tests with fewer assertions.","Raise or configure the max option if the count is intentional."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}