Skip to content

Commit

Permalink
Merge pull request #554 from visionmedia/use-trust-localhost
Browse files Browse the repository at this point in the history
Update superagent + use trustLocalhost()
  • Loading branch information
rimiti committed Mar 9, 2019
2 parents 1792d7d + 647ade8 commit 5914936
Show file tree
Hide file tree
Showing 5 changed files with 2,022 additions and 875 deletions.
240 changes: 0 additions & 240 deletions History.md

This file was deleted.

21 changes: 18 additions & 3 deletions README.md
@@ -1,4 +1,4 @@
# SuperTest
# SuperTest

[![Coveralls][coverage-badge]][coverage]
[![Build Status][travis-badge]][travis]
Expand Down Expand Up @@ -81,6 +81,21 @@ describe('GET /user', function() {
});
```

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.

```js
describe('GET /user', function() {
it('responds with json via HTTPS on localhost', function(done) {
request(app)
.get('/user')
.trustLocalhost()
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200, done);
});
});
```

One thing to note with the above statement is that superagent now sends any HTTP
error (anything other than a 2XX response code) to the callback as the first argument if
you do not add a status code expect (i.e. `.expect(302)`).
Expand Down Expand Up @@ -206,9 +221,9 @@ describe('request.agent(app)', function() {
});
});
```

There is another example that is introduced by the file [agency.js](https://github.com/visionmedia/superagent/blob/master/test/node/agency.js)

Here is an example where 2 cookies are set on the request.

```js
Expand Down

0 comments on commit 5914936

Please sign in to comment.