From b8ac9e29b59e7e32d90a9d1c8e7a0efa66ea7efd Mon Sep 17 00:00:00 2001
From: cmorten SuperOak
SuperOak is also available on nest.land, a package registry for Deno on the Blockchain.
-Note: All examples in this README are using the unversioned form of the import URL. In production you should always use the versioned import form such as
+https://deno.land/x/superoak@4.7.0/mod.ts
.Note: All examples in this README are using the unversioned form of the import URL. In production you should always use the versioned import form such as
https://deno.land/x/superoak@4.8.0/mod.ts
.
.end()
.
SuperOak works with any Deno test framework. Here's an example with Deno's built-in test framework.
-import { Application, Router } from "https://deno.land/x/oak@v10.4.0/mod.ts";
-import { superoak } from "https://deno.land/x/superoak@4.7.0/mod.ts";
+ import { Application, Router } from "https://deno.land/x/oak@v12.6.2/mod.ts";
+import { superoak } from "https://deno.land/x/superoak@4.8.0/mod.ts";
const router = new Router();
router.get("/", (ctx) => {
@@ -162,7 +162,8 @@ Example
// https://visionmedia.github.io/superagent/#post--put-requests.
Deno.test("it should allow post requests", async () => {
const request = await superoak(app);
- await request.post("/user")
+ await request
+ .post("/user")
.set("Content-Type", "application/json")
.send('{"name":"superoak"}')
.expect(200);
@@ -230,26 +231,35 @@ Request has been terminated
error
Instead you should make all of your assertions on a single SuperOak instance, or
create a new SuperOak instance for subsequent assertions like below:
// ✅ works
-Deno.test("it will allow you to make multiple assertions on one SuperOak instance", async () => {
- const request = await superoak(app);
- await request.get("/").expect(200).expect("Hello Deno!");
-});
+Deno.test(
+ "it will allow you to make multiple assertions on one SuperOak instance",
+ async () => {
+ const request = await superoak(app);
+ await request.get("/").expect(200).expect("Hello Deno!");
+ }
+);
// ✅ works
-Deno.test("it will allow you to re-use the Application for another SuperOak instance", async () => {
- const request1 = await superoak(app);
- await request1.get("/").expect(200);
+Deno.test(
+ "it will allow you to re-use the Application for another SuperOak instance",
+ async () => {
+ const request1 = await superoak(app);
+ await request1.get("/").expect(200);
- const request2 = await superoak(app);
- await request2.get("/").expect("Hello Deno!");
-});
+ const request2 = await superoak(app);
+ await request2.get("/").expect("Hello Deno!");
+ }
+);
// ❌ won't work
-Deno.test("it will throw an error if try to re-use a SuperOak instance", async () => {
- const request = await superoak(app);
- await request.get("/").expect(200);
- await request.get("/").expect("Hello Deno!"); // Boom 💥 `Error: Request has been terminated`
-});
+Deno.test(
+ "it will throw an error if try to re-use a SuperOak instance",
+ async () => {
+ const request = await superoak(app);
+ await request.get("/").expect(200);
+ await request.get("/").expect("Hello Deno!"); // Boom 💥 `Error: Request has been terminated`
+ }
+);
Contributing
diff --git a/docs/modules/_superoak_.html b/docs/modules/_superoak_.html
index 1dde37e..6fb4d77 100644
--- a/docs/modules/_superoak_.html
+++ b/docs/modules/_superoak_.html
@@ -91,7 +91,7 @@ Private isOakApplicat
Private random
superoak