Constructor
new SuperRest(app, optionsopt)
- Source:
- See:
Returns a SuperREST instance to test the specified application.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
app |
Application | The application to test. |
|||||||||||||||||||||
options |
object |
<optional> |
SuperREST configuration that applies to your entire API. Properties
|
Methods
create(path, body, optionsopt)
Makes a POST request to create a resource with the specified body. The response is expected to have the status code HTTP 201 Created by default.
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
path |
string | The path of the API resource.
If a non-false |
|||||||||||
body |
* | The request body to send to the server. |
|||||||||||
options |
object |
<optional> |
Assertion options (see SuperRest#test for all options). Properties
|
delete(path, bodyopt, optionsopt)
Makes a DELETE request to delete a resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | The path of the API resource.
If a non-false |
|
body |
* |
<optional> |
An optional request body to send to the server. |
options |
object |
<optional> |
Assertion options (see SuperRest#test for all options). |
destroy(path, bodyopt, optionsopt)
Makes a DELETE request to destroy a resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | The path of the API resource.
If a non-false |
|
body |
* |
<optional> |
An optional request body to send to the server. |
options |
object |
<optional> |
Assertion options (see SuperRest#test for all options). |
expect(res, optionsopt)
Make default RESTful assertions on a SuperTest response.
This method is used by SuperRest#test (and all CRUD aliases). You may override it to perform additional assertions.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
res |
Response | A SuperTest response. |
||||||||||||||||
options |
object |
<optional> |
Assertion options. Properties
|
patch(path, body, optionsopt)
Makes a PATCH request to partially update a resource with the specified body.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | The path of the API resource.
If a non-false |
|
body |
* | The request body to send to the server. |
|
options |
object |
<optional> |
Assertion options (see SuperRest#test for all options). |
read(path, optionsopt)
Makes a GET request to read a resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | The path of the API resource.
If a non-false |
|
options |
object |
<optional> |
Assertion options (see SuperRest#test for all options). |
retrieve(path, optionsopt)
Makes a GET request to retrieve a resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | The path of the API resource.
If a non-false |
|
options |
object |
<optional> |
Assertion options (see SuperRest#test for all options). |
test(methodopt, path, bodyopt, optionsopt)
Starts and returns a SuperTest chain.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
method |
string |
<optional> |
"GET"
|
The HTTP method. |
||||||||||||||||||||
path |
string | The path of the API resource to test.
If a non-false |
||||||||||||||||||||||
body |
* |
<optional> |
The request body to send to the server, if any. |
|||||||||||||||||||||
options |
object |
<optional> |
Test options. Properties
|
update(path, body, optionsopt)
Makes a PUT request to update a resource with the specified body.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string | The path of the API resource.
If a non-false |
|
body |
* | The request body to send to the server. |
|
options |
object |
<optional> |
Assertion options (see SuperRest#test for all options). |