Socket
Socket
Sign inDemoInstall

foxxsupertest

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    foxxsupertest

HTTP assertions adopted from Supertest for ArangoDB Foxx


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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 = require("foxxsupertest")(applicationContext, "http://localhost:8529");
describe("GET /test", function(){
  it("should responds with 200", function(done){
    request
      .get('/test')
      .expect(200)
      .end(function(err, res){
        if(err) throw err;
        done();
      });
  });
}

As the original SuperTest, you can add many expect with different types:

let request = require("foxxsupertest")(applicationContext, "http://localhost:8529");
describe("GET /test", function(){
  it("should responds with json and 200", function(done){
    request
      .get('/test')
      .expect('Content-Type', /json/)
      .expect(200)
      .end(function(err, res){
        if(err) throw err;
        done();
      });
  });
}

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 = require("foxxsupertest")(applicationContext, "http://localhost:8529");
describe("GET /users", function(){
  it("should responds with json and 200", function(done){
    request
      .post('/test',{
        auth: {
          username : "test",
          password : "test"
        },
        body: {
          content: "content to post"
        },
        json: true
      })
      .expect('Content-Type', /json/)
      .expect(200)
      .end(function(err, res){
        if(err) throw err;
        done();
      });
  });
}

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

Keywords

FAQs

Last updated on 23 Jun 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc