{"record":{"id":"7686d41187822c55","repo":"denoland/deno","slug":"test-failed-because-the-only-option-was-used","errorCode":null,"errorMessage":"Test failed because the \"only\" option was used","messagePattern":"Test failed because the \"only\" option was used","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/lsp/testing/execution.rs","lineNumber":503,"sourceCode":"              // `TestEvent::Result`.\n            }\n            test::TestEvent::Completed => {\n              reporter.report_completed();\n            }\n            // LSP-driven test runs never use `--update-snapshots`.\n            test::TestEvent::SnapshotSummary(_) => {}\n            test::TestEvent::ForceEndReport => {}\n            test::TestEvent::Sigint => {}\n            test::TestEvent::Exit(_) => {}\n            test::TestEvent::IsolateExit(_, _) => {}\n          }\n        }\n\n        let elapsed = Instant::now().duration_since(earlier);\n        reporter.report_summary(&summary, &elapsed);\n\n        if used_only {\n          return Err(anyhow!(\n            \"Test failed because the \\\"only\\\" option was used\"\n          ));\n        }\n\n        if summary.failed > 0 {\n          return Err(anyhow!(\"Test failed\"));\n        }\n\n        Ok(())\n      })\n    };\n\n    let (join_results, result) = future::join(join_stream, handler).await;\n\n    // propagate any errors\n    for join_result in join_results {\n      join_result??;\n    }","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/lsp/testing/execution.rs#L485-L521","documentation":"The Deno language server's test runner (backing the VS Code Deno extension's Test Explorer) fails the entire run if any executed module used the \"only\" filter (Deno.test(..., { only: true }, ...) or it.only). This is deliberate: an only-filtered run skips most tests, and reporting it green could hide failures. The flag latches when the test event stream reports plan.used_only for any module (cli/lsp/testing/execution.rs:417) and the error is returned after the summary is printed.","triggerScenarios":"Starting a test run from the IDE Test Explorer while any test in the run scope declares { only: true } (or a .only variant for BDD-style tests). The run executes only that subset, then the handler returns this error instead of Ok even though the executed tests may all have passed.","commonSituations":"A developer isolates one test with only: true during debugging and forgets to remove it before running the suite in the IDE; teams that treat IDE test runs as authoritative gate their PRs on a red run caused by a leftover filter.","solutions":["Search the workspace for `only: true` and `.only(` in test files, remove the flags, and re-run.","Use the Test Explorer's run-single-test action or `deno test --filter <name>` to focus a test instead of using only.","Add a pre-commit/pre-run grep or lint step for only-markers in test files so leftovers are caught before a run."],"exampleFix":"// before\nDeno.test(\"adds numbers\", { only: true }, () => {\n  assertEquals(1 + 1, 2);\n});\n\n// after\nDeno.test(\"adds numbers\", () => {\n  assertEquals(1 + 1, 2);\n});","handlingStrategy":"validation","validationCode":"// Scan test sources before an IDE run so a leftover `only` doesn't fail\n// the whole LSP test run.\nconst ONLY_PATTERNS = [/\\bonly\\s*:\\s*true/, /\\.only\\s*\\(/, /\\bit\\.only\\b/];\nexport function assertNoOnlyFlags(source, path) {\n  for (const re of ONLY_PATTERNS) {\n    if (re.test(source)) {\n      throw new Error(`${path} contains an 'only' test filter — remove it before running the suite`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"// When driving LSP test runs programmatically, branch on this exact failure.\ntry {\n  await runTests(session, modules);\n} catch (err) {\n  if (err?.message?.includes('\"only\" option was used')) {\n    // the executed subset may have passed, but the run must not count as green:\n    // strip `only` flags and re-run, or mark the run as blocked\n  } else {\n    throw err;\n  }\n}","preventionTips":["Focus a single test via the Test Explorer gutter or 'deno test --filter <name>' instead of adding only: true","Grep for 'only:' and '.only(' in test files before committing","Treat IDE runs that report the only error as failed even if the executed subset passed — that is the intended semantics"],"tags":["testing","deno-test","only","lsp","test-explorer"],"backgroundTag":"test-run-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}