Skip to content

Latest commit

 

History

History
53 lines (32 loc) · 1.67 KB

README.md

File metadata and controls

53 lines (32 loc) · 1.67 KB

Deno API Tests Coverage

Coverage Status

Demonstrates code coverage measurement of a Deno server when running Postman (newman) API tests.

See accompanying blog post for more details.

Requirements

Deno v1.26 (or higher) installed and available on path.

Usage

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:

  1. Start the Deno server to be tested (src/server.ts).
  2. Run Postman API tests using newman in a subprocess.
  3. Stop the server.

Background

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.

License

MIT