Skip to content

feat: add debug test support#18

Open
k1w1 wants to merge 1 commit into
Julien-R44:mainfrom
k1w1:feat/debug-tests
Open

feat: add debug test support#18
k1w1 wants to merge 1 commit into
Julien-R44:mainfrom
k1w1:feat/debug-tests

Conversation

@k1w1
Copy link
Copy Markdown

@k1w1 k1w1 commented May 12, 2026

Summary

  • Adds Debug test, Debug test file, and Debug latest test commands that launch the VS Code Node debugger (pwa-node) instead of running in a terminal
  • Adds "Debug test" and "Debug tests for this file" CodeLenses alongside the existing run lenses
  • Adds a Debug run profile to the VS Code Test Explorer (the triangular debug icon next to each test)
  • New keyboard shortcuts: Ctrl+Alt+D (debug test at cursor), Ctrl+Alt+Shift+D (debug test file)

How it works

A new DebugInvoker class (src/debugger/index.ts) calls vscode.debug.startDebugging() with a pwa-node launch config that invokes npm run <script> -- --files <file> --tests <name>. This lets VS Code attach its debugger so breakpoints set inside test files are hit normally.

The approach mirrors what the vitest VS Code extension does — using vscode.debug.startDebugging with runtimeExecutable: 'npm' and autoAttachChildProcesses: true.

Test plan

  • Open a Japa test file — "Run test" and "Debug test" CodeLenses appear above each test
  • Click Debug test — VS Code debug session starts, breakpoints in the test file are hit
  • Click Debug tests for this file — debugger runs all tests in the file
  • Use Ctrl+Alt+D shortcut to debug the test at the cursor
  • Use the Test Explorer debug profile (triangular play icon) to debug selected tests
  • Confirm Run code paths are unaffected

Adds the ability to debug individual tests, test files, and the latest
test using VS Code's built-in Node debugger (pwa-node), mirroring the
pattern established by the vitest VS Code extension.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@k1w1
Copy link
Copy Markdown
Author

k1w1 commented May 12, 2026

Woah, I got a bit ahead of myself here. I thought I was just pushing this up to my fork. I have some more validation to do.

@k1w1 k1w1 marked this pull request as draft May 12, 2026 22:44
@k1w1 k1w1 marked this pull request as ready for review May 12, 2026 23:35
@k1w1
Copy link
Copy Markdown
Author

k1w1 commented May 12, 2026

I have verified that it works as expected on my project. Debug buttons appear, and function, and debugging stops at breakpoints in the test and anywhere else in the code.

5/10 unit tests are failing, but that is the same as main.

Link above test to debug:

Screenshot 2026-05-12 at 4 36 32 PM

Button to debug next to each test:

Screenshot 2026-05-12 at 4 36 45 PM

Debugging related commands:

Screenshot 2026-05-12 at 4 36 59 PM

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.

1 participant