Skip to content

anishkny/deno-api-tests-coverage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Measure code coverage of a Deno server when running Postman (newman) API tests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published