Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
chai-connect-middleware
Advanced tools
Helpers for testing Connect middleware with the Chai assertion library.
Helpers for testing Connect middleware with the Chai assertion library.
$ npm install chai-connect-middleware
Use this plugin as you would all other Chai plugins:
var chai = require('chai');
chai.use(require('chai-connect-middleware'));
Once used, the chai.connect.use
helper function will be available to set up
test cases for Connect middleware.
The helper function can be called from a hook to setup the test case. The
helper returns a wrapper on which callbacks are registered to be executed
when the middleware invokes next
or end
s the response. If the middleware
finishes in an unexpected way, the test helper will automatically throw an
exception.
The following demonstrates a Mocha test case.
describe('middleware test', function() {
var res;
before(function(done) {
chai.connect.use(middleware)
.req(function(req) {
req.query = { hello: 'Bob' };
})
.end(function(r) {
res = r;
done();
})
.dispatch();
});
it('should send correct body', function() {
expect(res.body).to.equal('Hello, Bob');
});
});
$ npm install
$ npm test
Copyright (c) 2013 Jared Hanson <http://jaredhanson.net/>
FAQs
Helpers for testing Connect middleware with the Chai assertion library.
The npm package chai-connect-middleware receives a total of 83 weekly downloads. As such, chai-connect-middleware popularity was classified as not popular.
We found that chai-connect-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.