Skip to content

feat(lsp): add "Debug" code lens for test steps#34742

Merged
littledivy merged 1 commit into
mainfrom
orch/divybot-436
Jun 4, 2026
Merged

feat(lsp): add "Debug" code lens for test steps#34742
littledivy merged 1 commit into
mainfrom
orch/divybot-436

Conversation

@divybot

@divybot divybot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

The LSP emits "▶ Run Test" / "Debug" code lenses above Deno.test calls (resolved by the deno.client.test command in the VS Code extension), but test steps only had the native test-explorer gutter "play" button — which can run a step but not debug it. This is the gap described in #21664.

Change

DenoTestCollector (in cli/lsp/code_lens.rs) now descends into test function bodies and emits the same "▶ Run Test" / "Debug" code lenses for each test step:

  • t.step(...) on the test context, including arbitrarily nested steps
  • destructured step(...) (e.g. Deno.test("t", ({ step }) => …))
  • BDD it(...) / it.only|ignore|skip(...) inside describe(...)

The step-detection logic mirrors the static collector in cli/lsp/testing/collectors.rs (which already powers the test-explorer tree), reusing its parse_test_context_param helper.

Why filter by the parent test name

deno test --filter matches top-level test names only (TestFilter::includes is applied per top-level test; steps always run with their parent). So each step lens filters by its enclosing top-level test name. "Debug" on a step therefore runs its parent test under the inspector — exactly the same test the gutter "play" button already runs, but now with the debugger attached and the user free to set a breakpoint inside the step.

Top-level code lens output is unchanged (the existing test_deno_test_collector unit test and lsp_code_lens_test integration test are untouched).

Tests

Added unit tests in cli/lsp/code_lens.rs covering t.step, destructured step, and BDD it steps. Run with cargo test -p deno --lib lsp::code_lens.

Closes #21664

Closes denoland/divybot#436

The LSP emits "▶ Run Test" / "Debug" code lenses above `Deno.test` calls
(via the `deno.client.test` command), but test steps only had the native
test-explorer gutter "play" button, which can run a step but not debug it.

Make `DenoTestCollector` descend into test bodies and emit the same
"Run Test" / "Debug" code lenses for each `t.step(...)` call (including
destructured `step(...)` and BDD `it(...)` inside `describe(...)`),
mirroring the static step detection in `cli/lsp/testing/collectors.rs`.

Because `deno test --filter` only matches top-level test names, each
step's lens filters by the enclosing top-level test name, so "Debug" on a
step runs its parent test under the inspector — the same test the gutter
"play" button runs, but now with the debugger attached.

Closes #21664

Co-Authored-By: Divy Srivastava <[email protected]>
divybot added a commit to divybot/deno that referenced this pull request Jun 3, 2026
@divybot

divybot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Here's the new Run Test | Debug code lens working on test steps, captured in browser-based VS Code (official Deno extension) driving this PR's deno lsp build:

Deno LSP Run Test | Debug code lenses on test steps

Every t.step(...), destructured step(...), and BDD it(...) inside describe(...) now gets its own ▶ Run Test | Debug lens (lines 5, 9, 15, 21, 25), alongside the existing top-level Deno.test / describe lenses. With a stock deno those step lenses are absent — they only show up with this PR's build (status bar: Deno 2.8.1).

Clicking Debug on a step runs its enclosing top-level test under the inspector (since deno test --filter matches top-level names only), matching the gutter "play" button but with the debugger attached.

@littledivy
littledivy merged commit 551973f into main Jun 4, 2026
136 checks passed
@littledivy
littledivy deleted the orch/divybot-436 branch June 4, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "debug" button for test steps in vscode

2 participants