In a new project, I create main.test.ts
, which contains assertions module:
import { assert } from "https://deno.land/std@0.224.0/assert/mod.ts";
Deno.test("Hello Test", () => {
assert("Hello");
});
console.log('done')
If I run it in the terminal it works fine:
deno test
Check file:///D:/Programming/test/deno/main.test.ts
------- pre-test output -------
done
----- pre-test output end -----
running 1 test from ./main.test.ts
Hello Test ... ok (0ms)
ok | 1 passed | 0 failed (2ms)
However, I would like to save a couple of key stroke and make use of the debugger. I create this .vscode/launch.json
file:
{
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Debug tests",
"type": "node",
"program": "${file}",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"test",
"--inspect-wait"
],
"attachSimplePort": 9229
}
]
}
The debug console only shows done
. I expect it to be like when I run it on the terminal. Is this possible?
It can, but you need to add "outputCapture": "std"
to the launch configuration in launch.json
. This is documented under the section for debugging Node in VS Code (Deno uses the same debugging protocol as Node).
outputCapture
- if set tostd
, output from the process stdout/stderr will be shown in the Debug Console, instead of listening to output over the debug port. This is useful for programs or log libraries that write directly to the stdout/stderr streams instead of usingconsole.*
APIs.
If I try your example with that property added...
{
"version": "0.2.0",
"configurations": [
{
"request": "launch",
"name": "Debug tests",
"type": "node",
"program": "${file}",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"test",
"--inspect-wait"
],
"attachSimplePort": 9229,
"outputCapture": "std"
}
]
}
...the debug console includes the full test output:
/usr/local/bin/deno test --inspect-wait ./main.test.ts
Check file:///workspaces/example/main.test.ts
Debugger listening on ws://127.0.0.1:9229/ws/c71476fd-7121-4d6e-8c72-a7cced6dfebb
Visit chrome://inspect to connect to the debugger.
Deno is waiting for debugger to connect.
Debugger session started.
------- pre-test output -------
done
----- pre-test output end -----
running 1 test from ./main.test.ts
Hello Test ... ok (0ms)
ok | 1 passed | 0 failed (14ms)