Skip to content

Commit

Permalink
Merge pull request #532 from visionmedia/v3.4.0
Browse files Browse the repository at this point in the history
V3.4.0
  • Loading branch information
rimiti committed Jan 16, 2019
2 parents e910e85 + 43bfae1 commit 60f8a9e
Show file tree
Hide file tree
Showing 7 changed files with 1,428 additions and 1,408 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
@@ -1,7 +1,14 @@
language: node_js

node_js:
- 6
- 8
- 10

before_install:
- npm i

script:
- npm run test

after_success: npm run coverage
7 changes: 7 additions & 0 deletions History.md
@@ -1,3 +1,10 @@
3.4.0 / 2019-01-15
===================

* PR-532 - Packages updated, pipeline more explicit, documentation updated (thanks @rimiti)
* PR-517 - Documentation updated (thanks @oprogramador)
* PR-513 - Use more robust Array instance check (thanks @rubendg)

3.3.0 / 2018-09-06
===================

Expand Down
32 changes: 31 additions & 1 deletion README.md
Expand Up @@ -55,7 +55,7 @@ request(app)

```js
describe('GET /user', function() {
it('respond with json', function(done) {
it('responds with json', function(done) {
request(app)
.get('/user')
.set('Accept', 'application/json')
Expand All @@ -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 Expand Up @@ -190,6 +203,23 @@ 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
agent(app)
.get('/api/content')
.set('Cookie', ['nameOne=valueOne;nameTwo=valueTwo'])
.send()
.expect(200)
.end((err, res) => {
if (err) {
return done(err);
}
expect(res.text).to.be.equal('hey');
return done();
});
```

## API

Expand Down
2 changes: 1 addition & 1 deletion lib/test.js
Expand Up @@ -236,7 +236,7 @@ Test.prototype._assertHeader = function(header, res) {

if (typeof actual === 'undefined') return new Error('expected "' + field + '" header field');
// This check handles header values that may be a String or single element Array
if ((actual instanceof Array && actual.toString() === fieldExpected)
if ((Array.isArray(actual) && actual.toString() === fieldExpected)
|| fieldExpected === actual) {
return;
}
Expand Down

0 comments on commit 60f8a9e

Please sign in to comment.