oxc-project/oxc · error · OxcDiagnostic
Require local Test Context for concurrent snapshot tests
Error message
Require local Test Context for concurrent snapshot tests
What it means
Emitted by the vitest/require-local-test-context-for-concurrent-snapshots rule at a `describe.concurrent`/`test.concurrent` usage that performs snapshot assertions. Concurrent tests in a shared worker share snapshot state, which corrupts results unless a local test context is used.
Source
Thrown at crates/oxc_linter/src/rules/vitest/require_local_test_context_for_concurrent_snapshots.rs:39
)
}
#[inline]
fn is_test_or_describe_node(member_expr: &MemberExpression) -> bool {
if let Some(id) = member_expr.object().get_identifier_reference()
&& matches!(
JestFnKind::from(id.name.as_str()),
JestFnKind::General(JestGeneralFnKind::Describe | JestGeneralFnKind::Test)
)
&& let Some(property_name) = member_expr.static_property_name()
{
return property_name == "concurrent";
}
false
}
fn require_local_test_context_for_concurrent_snapshots_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Require local Test Context for concurrent snapshot tests")
.with_help("Use local Test Context instead")
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct RequireLocalTestContextForConcurrentSnapshots;
declare_oxc_lint!(
/// ### What it does
///
/// The rule is intended to ensure that concurrent snapshot tests are executed
/// within a properly configured local test context.
///
/// ### Why is this bad?
///
/// Running snapshot tests concurrently without a proper context can lead to
/// unreliable or inconsistent snapshots. Ensuring that concurrent tests are
/// correctly configured with the appropriate context helps maintain accurateView on GitHub (pinned to e1e7af627c)
Solutions
- Accept a local test context in the concurrent test, e.g. `test.concurrent('...', ({ expect }) => { expect(...).toMatchSnapshot() })` and use the context's `expect` for snapshots
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vitest/require_local_test_context_for_concurrent_snapshots.rs:39 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/6d767ea128ee55c4.
Report an issue: GitHub.