Skip to content

Commit 5914936

Browse files
authored
Merge pull request #554 from visionmedia/use-trust-localhost
Update superagent + use trustLocalhost()
2 parents 1792d7d + 647ade8 commit 5914936

File tree

5 files changed

+2022
-875
lines changed

5 files changed

+2022
-875
lines changed

History.md

Lines changed: 0 additions & 240 deletions
This file was deleted.

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SuperTest
1+
# SuperTest
22

33
[![Coveralls][coverage-badge]][coverage]
44
[![Build Status][travis-badge]][travis]
@@ -81,6 +81,21 @@ describe('GET /user', function() {
8181
});
8282
```
8383

84+
If you need to test with HTTPS against localhost, you can use superagent's `.trustLocalhost()`, which let's you bypass any errors related to broken/insecure HTTPS on localhost.
85+
86+
```js
87+
describe('GET /user', function() {
88+
it('responds with json via HTTPS on localhost', function(done) {
89+
request(app)
90+
.get('/user')
91+
.trustLocalhost()
92+
.set('Accept', 'application/json')
93+
.expect('Content-Type', /json/)
94+
.expect(200, done);
95+
});
96+
});
97+
```
98+
8499
One thing to note with the above statement is that superagent now sends any HTTP
85100
error (anything other than a 2XX response code) to the callback as the first argument if
86101
you do not add a status code expect (i.e. `.expect(302)`).
@@ -206,9 +221,9 @@ describe('request.agent(app)', function() {
206221
});
207222
});
208223
```
209-
224+
210225
There is another example that is introduced by the file [agency.js](https://github.com/visionmedia/superagent/blob/master/test/node/agency.js)
211-
226+
212227
Here is an example where 2 cookies are set on the request.
213228

214229
```js

0 commit comments

Comments
 (0)