FoxxSupertest
HTTP assertions adopted from Supertest for ArangoDB Foxx
Requirements
You will need to have at least ArangoDb 2.6 installed.
Installation
npm install foxxsupertest
Instructions
You will need to pass the following option when you first initialize the module:
applicationContext
: This is the default global application context variable within your Foxx app.serverAddress
: Your ArangoDB server address, e.g:http://localhost:8529
.baseURL
: Your database mounting point (not the Foxx mounting point), e.g:/_db/_system
.
Examples
FoxxSupertest works well with Mocha shipped-in with ArangoDB 2.6. The following examples demonstrate how it works as it differ a little bit from the original Supertest:
let request = applicationContext "http://localhost:8529";
As the original SuperTest, you can add many expect
with different types:
let request = applicationContext "http://localhost:8529";
If you want to add headers and content to your request, you will need to add them to the request options since FoxxSupertest uses the request module shipped with ArangoDB to simulate the http requests:
let request = applicationContext "http://localhost:8529";
API
FoxxSupertest uses the similar API which Supertest uses:
.expect(status[, fn])
Assert response status
code.
.expect(status, body[, fn])
Assert response status
code and body
.
.expect(body[, fn])
Assert response body
text with a string, regular expression, or
parsed body object.
.expect(field, value[, fn])
Assert header field
value
with a string or regular expression.
.end(fn)
Perform the request and invoke fn(err, res)
.
Notes
As we mentioend before, this module was adopted from Supertest, hence we resued some of the original source code to work with this module
Author
Omar A. Al-Safi (omarsmak@gmail.com, omar@fedger.io)
License
MIT