Demonstrates code coverage measurement of a Deno server when running Postman (newman
) API tests.
See accompanying blog post for more details.
Deno v1.26 (or higher) installed and available on path.
Clone this repository and execute:
deno task test
This runs the test file ./test/server_test.ts
and collects resulting code coverage.
The test file takes the following steps:
- Start the Deno server to be tested (
src/server.ts
). - Run Postman API tests using
newman
in a subprocess. - Stop the server.
Deno lacks a way to measure code coverage of a server when running API tests. See this discussion on the Deno repo.
Ideally, there would be a way to start a server thus:
deno run --coverage=coverage src/server.ts # Doesn't work
# Run API tests
# Kill server
Instead you have to start the server, run API tests by shelling out to a process and then stop the server, in the test itself.
deno test --coverage=coverage test/server_test.ts ... # Workaround
This repo demonstrates how to do that. See test/run-tests.sh which runs test/server_test.ts.
Also, see accompanying blog post for more details.