@@ -18,7 +18,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
1818</p >
1919<p align =" center " >
2020 <a href =" https://deno.land/x/superdeno " ><img src =" https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fsuperdeno%2Fmod.ts " alt =" SuperDeno latest /x/ version " /></a >
21- <a href =" https://github.com/denoland/deno/blob/main/Releases.md " ><img src =" https://img.shields.io/badge/deno-^1.19.3 -brightgreen?logo=deno " alt =" Minimum supported Deno version " /></a >
21+ <a href =" https://github.com/denoland/deno/blob/main/Releases.md " ><img src =" https://img.shields.io/badge/deno-^1.40.2 -brightgreen?logo=deno " alt =" Minimum supported Deno version " /></a >
2222 <a href =" https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/superdeno/mod.ts " ><img src =" https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fdep-count%2Fx%2Fsuperdeno%2Fmod.ts " alt =" SuperDeno dependency count " /></a >
2323 <a href =" https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/superdeno/mod.ts " ><img src =" https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fupdates%2Fx%2Fsuperdeno%2Fmod.ts " alt =" SuperDeno dependency outdatedness " /></a >
2424 <a href =" https://deno-visualizer.danopia.net/dependencies-of/https/deno.land/x/superdeno/mod.ts " ><img src =" https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Fcache-size%2Fx%2Fsuperdeno%2Fmod.ts " alt =" SuperDeno cached size " /></a >
@@ -31,7 +31,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
3131- [ Getting Started] ( #getting-started )
3232- [ About] ( #about )
3333- [ Installation] ( #installation )
34- - [ Example ] ( #example )
34+ - [ Examples ] ( #examples )
3535- [ Documentation] ( #documentation )
3636- [ API] ( #api )
3737- [ Notes] ( #notes )
@@ -42,7 +42,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
4242
4343``` ts
4444import { superdeno } from " https://deno.land/x/superdeno/mod.ts" ;
45- import { opine } from " https://deno.land/x/opine@1.9.1 /mod.ts" ;
45+ import { opine } from " https://deno.land/x/opine@2.3.4 /mod.ts" ;
4646
4747const app = opine ();
4848
@@ -85,9 +85,9 @@ import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
8585SuperDeno is also available on [ nest.land] ( https://nest.land/package/superdeno ) ,
8686a package registry for Deno on the Blockchain.
8787
88- > 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/superdeno@4.8 .0/mod.ts ` .
88+ > 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/superdeno@4.9 .0/mod.ts ` .
8989
90- ## Example
90+ ## Examples
9191
9292You may pass a url string,
9393[ ` http.Server ` ] ( https://doc.deno.land/https/deno.land/std/http/mod.ts#Server ) , a
@@ -116,8 +116,8 @@ Here's an example of SuperDeno working with the Opine web framework:
116116
117117``` ts
118118import { superdeno } from " https://deno.land/x/superdeno/mod.ts" ;
119- import { opine } from " https://deno.land/x/opine@1.9.1 /mod.ts" ;
120- export { expect } from " https://deno.land/x/expect@v0.2.9 /mod.ts" ;
119+ import { opine } from " https://deno.land/x/opine@2.3.4 /mod.ts" ;
120+ import { expect } from " https://deno.land/x/expect@v0.4.0 /mod.ts" ;
121121
122122const app = opine ();
123123
@@ -129,19 +129,49 @@ Deno.test("it should support regular expressions", async () => {
129129 await superdeno (app )
130130 .get (" /" )
131131 .expect (" Content-Type" , / ^ application/ )
132- .end ((err ) => {
132+ .catch ((err ) => {
133133 expect (err .message ).toEqual (
134- ' expected "Content-Type" matching /^application/, got "text/html; charset=utf-8"' ,
134+ ' expected "Content-Type" matching /^application/, got "text/html; charset=utf-8"'
135135 );
136136 });
137137});
138138```
139139
140+ See more examples in the [ Opine test suite] ( ./test/superdeno.opine.test.ts ) .
141+
142+ Here's an example of SuperDeno working with the Express web framework:
143+
144+ ``` ts
145+ import { superdeno } from " https://deno.land/x/superdeno/mod.ts" ;
146+ // @deno-types="npm:@types/express@^4.17"
147+ import express from " npm:[email protected] " ;
148+ import {
expect }
from " https://deno.land/x/[email protected] /mod.ts" ;
149+
150+ Deno .test (" it should support regular expressions" , async () => {
151+ const app = express ();
152+
153+ app .get (" /" , (_req , res ) => {
154+ res .send (" Hello Deno!" );
155+ });
156+
157+ await superdeno (app )
158+ .get (" /" )
159+ .expect (" Content-Type" , / ^ application/ )
160+ .catch ((err ) => {
161+ expect (err .message ).toEqual (
162+ ' expected "Content-Type" matching /^application/, got "text/html; charset=utf-8"'
163+ );
164+ });
165+ });
166+ ```
167+
168+ See more examples in the [ Express test suite] ( ./test/superdeno.express.test.ts ) .
169+
140170Here's an example of SuperDeno working with the Oak web framework:
141171
142172``` ts
143173import { superdeno } from " https://deno.land/x/superdeno/mod.ts" ;
144- import { Application , Router } from " https://deno.land/x/oak@v10.0.0 /mod.ts" ;
174+ import { Application , Router } from " https://deno.land/x/oak@v12.6.2 /mod.ts" ;
145175
146176const router = new Router ();
147177router .get (" /" , (ctx ) => {
@@ -171,6 +201,8 @@ Deno.test("it should support the Oak framework", () => {
171201});
172202```
173203
204+ See more examples in the [ Oak test suite] ( ./test/superdeno.oak.test.ts ) .
205+
174206If you are using the [ Oak] ( https://github.com/oakserver/oak/ ) web framework then
175207it is recommended that you use the specialized
176208[ SuperOak] ( https://github.com/cmorten/superoak ) assertions library for
@@ -181,7 +213,7 @@ are making use of the `app.handle()` method (for example for serverless apps)
181213then you can write slightly less verbose tests for Oak:
182214
183215``` ts
184- import { Application , Router } from " https://deno.land/x/oak@v10.0.0 /mod.ts" ;
216+ import { Application , Router } from " https://deno.land/x/oak@v12.6.2 /mod.ts" ;
185217import { superdeno } from " https://deno.land/x/superdeno/mod.ts" ;
186218
187219const router = new Router ();
@@ -194,15 +226,16 @@ const app = new Application();
194226app .use (router .routes ());
195227app .use (router .allowedMethods ());
196228
197- Deno .test (" it should support the Oak framework `app.handle` method" , async () => {
198- /**
199- * Note that we have to bind `app` to the function otherwise `app.handle`
200- * doesn't preserve the `this` context from `app`.
201- */
202- await superdeno (app .handle .bind (app ))
203- .get (" /" )
204- .expect (" Hello Deno!" );
205- });
229+ Deno .test (
230+ " it should support the Oak framework `app.handle` method" ,
231+ async () => {
232+ /**
233+ * Note that we have to bind `app` to the function otherwise `app.handle`
234+ * doesn't preserve the `this` context from `app`.
235+ */
236+ await superdeno (app .handle .bind (app )).get (" /" ).expect (" Hello Deno!" );
237+ }
238+ );
206239```
207240
208241In this case, SuperDeno handles the setup and closing of the server for you, so
0 commit comments