@@ -18,7 +18,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
18
18
</p >
19
19
<p align =" center " >
20
20
<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 >
22
22
<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 >
23
23
<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 >
24
24
<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
31
31
- [ Getting Started] ( #getting-started )
32
32
- [ About] ( #about )
33
33
- [ Installation] ( #installation )
34
- - [ Example ] ( #example )
34
+ - [ Examples ] ( #examples )
35
35
- [ Documentation] ( #documentation )
36
36
- [ API] ( #api )
37
37
- [ Notes] ( #notes )
@@ -42,7 +42,7 @@ HTTP assertions for Deno made easy via <a href="https://github.com/visionmedia/s
42
42
43
43
``` ts
44
44
import { 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" ;
46
46
47
47
const app = opine ();
48
48
@@ -85,9 +85,9 @@ import { superdeno } from "https://deno.land/x/superdeno/mod.ts";
85
85
SuperDeno is also available on [ nest.land] ( https://nest.land/package/superdeno ) ,
86
86
a package registry for Deno on the Blockchain.
87
87
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 ` .
89
89
90
- ## Example
90
+ ## Examples
91
91
92
92
You may pass a url string,
93
93
[ ` 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:
116
116
117
117
``` ts
118
118
import { 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" ;
121
121
122
122
const app = opine ();
123
123
@@ -129,19 +129,49 @@ Deno.test("it should support regular expressions", async () => {
129
129
await superdeno (app )
130
130
.get (" /" )
131
131
.expect (" Content-Type" , / ^ application/ )
132
- .end ((err ) => {
132
+ .catch ((err ) => {
133
133
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"'
135
135
);
136
136
});
137
137
});
138
138
```
139
139
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
+
140
170
Here's an example of SuperDeno working with the Oak web framework:
141
171
142
172
``` ts
143
173
import { 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" ;
145
175
146
176
const router = new Router ();
147
177
router .get (" /" , (ctx ) => {
@@ -171,6 +201,8 @@ Deno.test("it should support the Oak framework", () => {
171
201
});
172
202
```
173
203
204
+ See more examples in the [ Oak test suite] ( ./test/superdeno.oak.test.ts ) .
205
+
174
206
If you are using the [ Oak] ( https://github.com/oakserver/oak/ ) web framework then
175
207
it is recommended that you use the specialized
176
208
[ 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)
181
213
then you can write slightly less verbose tests for Oak:
182
214
183
215
``` 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" ;
185
217
import { superdeno } from " https://deno.land/x/superdeno/mod.ts" ;
186
218
187
219
const router = new Router ();
@@ -194,15 +226,16 @@ const app = new Application();
194
226
app .use (router .routes ());
195
227
app .use (router .allowedMethods ());
196
228
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
+ );
206
239
```
207
240
208
241
In this case, SuperDeno handles the setup and closing of the server for you, so
0 commit comments