Skip to content

Commit

Permalink
Merge pull request ladjs#27 from mfrobben/master
Browse files Browse the repository at this point in the history
Simple documentation update. Closes issue ladjs#11
  • Loading branch information
tj committed Oct 7, 2012
2 parents c512e94 + 55d7274 commit 07200e3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Readme.md
Expand Up @@ -48,6 +48,26 @@ describe('GET /users', function(){
.expect(200, done);
})
})
```

If you are using the `.end()` syntax with mocha, `.expect()` assertions that fail will
not throw - they will return the assertion as an error to the `.end()` callback. In
order to fail the test case, you will need to rethrow or pass `err` to `done()`, as follows:

```js
describe('GET /users', function(){
it('respond with json', function(done){
request(app)
.get('/user')
.set('Accept', 'application/json')
.expect(200)
.end(function(err, res){
if (err)
return done(err) // if response is 500 or 404, test case will fail
done()
});
})
})
```

Anything you can do with superagent, you can do with supertest - for example multipart file uploads!
Expand Down

0 comments on commit 07200e3

Please sign in to comment.