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

Clarify that .end(..) closes the server #369

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ describe('GET /users', function() {
});
});
```
Also mind:
- if you are using the `.end()` method - it closes the server, even if you initially provided it running.
- the `this` keyword in the callback passed to `.end()` is the instance of `supertest.Test` class that manages the test.

Expectations are run in the order of definition. This characteristic can be used
to modify the response body or headers before executing an assertion.


```js
describe('GET /user', function() {
Expand Down Expand Up @@ -210,6 +214,8 @@ describe('request.agent(app)', function(){
### .end(fn)

Perform the request and invoke `fn(err, res)`.
If the call was created with an instance of a server - it **closes** the server, wether it was bound to a port or not.
Also mind that the `this` context inside the callback is set to the `supertest.Test` instance, and not the mocha test or any other context you're running in.

## Notes

Expand Down