Skip to content

Commit

Permalink
Merge pull request #519 from oprogramador/patch-3
Browse files Browse the repository at this point in the history
Adding auth example into README file
  • Loading branch information
rimiti committed Nov 20, 2018
2 parents 6ca3897 + 0146d81 commit 50c59d6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -65,6 +65,19 @@ describe('GET /user', function() {
});
```

You can use `auth` method to pass HTTP username and password in the same way as in the [superagent](http://visionmedia.github.io/superagent/#authentication):
```js
describe('GET /user', function() {
it('responds with json', function(done) {
request(app)
.get('/user')
.auth('username', 'password')
.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

0 comments on commit 50c59d6

Please sign in to comment.