Socket
Socket
Sign inDemoInstall

supertest-chai

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    supertest-chai

Super-agent driven library for testing HTTP servers with Chai asserts


Version published
Weekly downloads
18
decreased by-47.06%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

supertest-chai

HTTP assertions made easy via super-agent and chai

Addresses problem with persisting cookies between requests (issues: https://github.com/visionmedia/supertest/issues/26 and https://github.com/visionmedia/supertest/issues/46).

Example

var supertestChai = require('supertest-chai');
var request = supertestChai.request;
var chai = require("chai");
chai.should();
chai.use(supertestChai.httpAsserts);

var express = require('express');

var app = express();

app.get('/user', function (req, res) {
    res.send(201, { name: 'tobi' });
});

app.get('/questions', function (req, res) {
    res.send(200, 'test');
});

request(app)
    .get('/user')
    .end(function (res) {
             res.should.be.json;
             res.should.have.status(201);
             res.should.have.header('Content-Length', '15');
             res.body.should.deep.equal({name: 'tobi'});
         });

// Access to superagent's agent, making requests using 'user' persists cookies ascross them
var user = request(app).agent();

user
    .get('/questions')
    .end(function (res) {
             res.should.be.html;
             res.should.have.status(200);
             res.should.have.header('Content-Length', '4');
             res.text.should.equal('test');
         });

Notes

Inspired by supertest and chai-http

License

MIT

Keywords

FAQs

Last updated on 24 Oct 2013

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