@@ -20,10 +20,15 @@ This is an addon plugin for the [Chai Assertion Library](https://www.chaijs.com/
20
20
Use this plugin as you would all other Chai plugins.
21
21
22
22
``` js
23
- import chaiModule from " chai" ;
23
+ import * as chai from " chai" ;
24
24
import chaiHttp from " chai-http" ;
25
25
26
- const chai = chaiModule .use (chaiHttp);
26
+ chai .use (chaiHttp);
27
+
28
+ // if you need to access `request`
29
+ import {default as chaiHttp , request } from " chai-http" ;
30
+ chai .use (chaiHttp);
31
+ request .get (... ).send (... );
27
32
```
28
33
29
34
To use Chai HTTP on a web page, please use the latest v4 version for now.
@@ -89,7 +94,7 @@ Once a request is created with a given VERB (get, post, etc), you chain on these
89
94
| ` .set(key, value) ` | Set request headers |
90
95
| ` .send(data) ` | Set request data (default type is JSON) |
91
96
| ` .type(dataType) ` | Change the type of the data sent from the ` .send() ` method (xml, form, etc) |
92
- | ` .attach(field, file, attachment) ` | Attach a file |
97
+ | ` .attach(field, file, attachment) ` | Attach a file |
93
98
| ` .auth(username, password) ` | Add auth headers for Basic Authentication |
94
99
| ` .query(parmasObject) ` | Chain on some GET parameters |
95
100
@@ -139,12 +144,12 @@ chai.request.execute(app)
139
144
chai .request .execute (app)
140
145
.get (' /protected' )
141
146
.auth (' user' , ' pass' )
142
-
147
+
143
148
// Authenticate with Bearer Token
144
149
chai .request .execute (app)
145
150
.get (' /protected' )
146
- .auth (accessToken, { type: ' bearer' })
147
-
151
+ .auth (accessToken, { type: ' bearer' })
152
+
148
153
```
149
154
150
155
` .query() `
0 commit comments