Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update superagent + use trustLocalhost() #554

Merged
merged 3 commits into from Mar 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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