{"record":{"id":"d62185794b726c93","repo":"oxc-project/oxc","slug":"no-async-describe-callback","errorCode":null,"errorMessage":"No async describe callback","messagePattern":"No async describe callback","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/shared/jest_vitest/valid_describe_callback.rs","lineNumber":18,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{Argument, Expression, FunctionBody, Statement},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    context::LintContext,\n    utils::{JestFnKind, JestGeneralFnKind, PossibleJestNode, parse_general_jest_fn_call},\n};\n\nfn valid_describe_callback_diagnostic(\n    x1: &'static str,\n    x2: &'static str,\n    span3: Span,\n) -> OxcDiagnostic {\n    OxcDiagnostic::warn(x1).with_help(x2).with_label(span3)\n}\n\n#[derive(Clone, Copy)]\npub struct ValidDescribeCallbackOptions {\n    allow_async_describe_callback: bool,\n    allow_describe_options_argument: bool,\n}\n\nimpl ValidDescribeCallbackOptions {\n    pub const JEST: Self =\n        Self { allow_async_describe_callback: false, allow_describe_options_argument: false };\n\n    pub const VITEST: Self =\n        Self { allow_async_describe_callback: true, allow_describe_options_argument: true };\n}\n\npub fn run<'a>(\n    possible_jest_node: &PossibleJestNode<'a, '_>,","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/shared/jest_vitest/valid_describe_callback.rs#L1-L36","documentation":"Diagnostic from the oxlint `jest/valid-describe-callback` rule (source: crates/oxc_linter/src/rules/shared/jest_vitest/valid_describe_callback.rs:18). This variant ('No async describe callback') fires when the describe callback is declared `async`. Describe callbacks only register tests; awaiting inside them skips registration depending on timing, so jest forbids it. The `allow_async_describe_callback` option in `ValidDescribeCallbackOptions` (Jest default: false) can relax this.","triggerScenarios":"`describe('feature', async () => { ... })` - an async function expression/arrow as the describe callback, with the rule option `allow_async_describe_callback` at its default `false` (the JEST preset constant in the source).","commonSituations":"Copy-pasting a test callback into a describe; dynamic test generation that fetches data before declaring tests (the correct pattern is hooks or top-level await in ESM); refactors that made everything async.","solutions":["Remove `async` from the describe callback and keep only synchronous registration: `describe('feature', () => { test(...) })`.","If the async work must happen before tests, do it inside `beforeAll(async () => {...})` - hooks may be async.","Use top-level await in an ESM test file when the data is available statically.","As a last resort enable the option: `\"jest/valid-describe-callback\": [\"error\", { \"allowAsyncDescribeCallback\": true }]` in `.oxlintrc.json`."],"exampleFix":"// before\ndescribe('config', async () => {\n  const cfg = await loadConfig();\n  test('has port', () => expect(cfg.port).toBeDefined());\n});\n\n// after\ndescribe('config', () => {\n  let cfg;\n  beforeAll(async () => {\n    cfg = await loadConfig();\n  });\n  test('has port', () => expect(cfg.port).toBeDefined());\n});","handlingStrategy":"validation","validationCode":"// rg -n \"describe\\([^)]*async\\s*\\(\\)\" tests/ -t ts -t js","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep describe callbacks synchronous; async work goes in beforeAll/afterAll or top-level await","When generating suites from async data, load in beforeAll, not in the describe callback"],"tags":["jest","vitest","oxlint","describe","async"],"backgroundTag":"jest-describe-callback-validation","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"}