DEV Community

Craig Morten
Craig Morten

Posted on • Updated on

Testing Your Deno Oak Server Applications

Excited to share that I've been working on a couple of testing libraries for Deno HTTP servers that are now ready to use!

  • SuperDeno - HTTP assertions for Deno made easy via superagent.
  • SuperOak - an extension to SuperDeno to provide easy HTTP assertions for Deno's popular Oak web framework.

Here's an example of how you can use SuperOak to test an Oak server:

// server.ts
import { Application, Router } from "";

const router = new Router();
router.get("/", (ctx) => {
  ctx.response.body = { message: "Hello Deno!" };
  ctx.response.status = 200;

const app = new Application();

export default app;

// server.test.ts
import { superoak } from "";
import app from "./server.ts";

 * Test that the server returns the "Hello Deno!" JSON object when make a
 * GET request to "/".
Deno.test("it should return some JSON with status code 200", async () => {
  const request = await superoak(app);
  await request.get("/")
    .expect("Content-Type", /json/)
    .expect('{"message":"Hello Deno!"}');
Enter fullscreen mode Exit fullscreen mode


Currently there is quite a lot of bootstrapping and setup required to test your Opine, Oak and other web framework applications.

These modules aim to provide an easy to use, high-level abstraction for testing HTTP in Deno, while still allowing you to drop down to a lower-level API provided by superagent.


This is a Deno module available to import direct from this repo and via the Deno Registry.

Before importing, download and install Deno.

You can then import SuperDeno or SuperOak straight into your project:

import { superdeno } from "";
import { superoak } from "";
Enter fullscreen mode Exit fullscreen mode

Further API docs and further examples are available in the GitHub READMEs (linked above)! πŸš€

Let me know how you're getting on with writing and testing your HTTP Servers in Deno! Questions, suggestions and issues all welcome - drop a message in the comments below or on in the GitHub repository issues section.

Happy testing! πŸ¦•

Top comments (2)

mark_tyers_462cb6380feba1 profile image
Mark Tyers

The sample code you provide throws 41 errors!

deno 1.18.2 (release, x86_64-apple-darwin)
typescript 4.5.2
Enter fullscreen mode Exit fullscreen mode

There were so many errors that the dev discussion board refused to post them since they exceeded the maximum post length.


craigmorten profile image
Craig Morten

Hey Mark!

This post is over a year old and unfortunately with the several changes to Deno in the time since, the out of date versions listed in this tutorial are no longer compatible (there have been a number of breaking changes in Deno for bug fixes).

Recommend using the examples in the repo and always upgrading to the latest version of Oak and SuperOak for the best results πŸ˜„