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. For your example, if we apply that change...
{
"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 will include the full test output:
/usr/local/bin/deno test --inspect-wait ./tests/example_test.ts
Check file:///workspaces/example/tests/example_test.ts
Debugger listening on ws://127.0.0.1:9229/ws/9113897c-720e-41b8-a313-200077018aa4
Visit chrome://inspect to connect to the debugger.
Deno is waiting for debugger to connect.
Debugger session started.
running 1 test from ./tests/example_test.ts
test1 ... ok (0ms)
ok | 1 passed | 0 failed (4ms)