diff --git a/package.json b/package.json index 2fb6ebaa..61e91899 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "nyc": "15.1.0", "pbkdf2-password": "1.2.1", "resolve-path": "1.4.0", - "should": "13.2.3", "supertest": "6.2.2", "vhost": "~3.0.2" }, diff --git a/test/Route.js b/test/Route.js index 005b4634..8e7ddbdb 100644 --- a/test/Route.js +++ b/test/Route.js @@ -1,7 +1,7 @@ 'use strict' var after = require('after'); -var should = require('should'); +var assert = require('assert') var express = require('../') , Route = express.Route , methods = require('methods') @@ -25,7 +25,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - should(req.called).be.ok() + assert.ok(req.called) done(); }); }) @@ -35,7 +35,7 @@ describe('Route', function(){ var route = new Route('/foo'); var cb = after(methods.length, function (err) { if (err) return done(err); - count.should.equal(methods.length); + assert.strictEqual(count, methods.length) done(); }); @@ -66,7 +66,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - req.count.should.equal(2); + assert.strictEqual(req.count, 2) done(); }); }) @@ -84,7 +84,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - should(req.called).be.ok() + assert.ok(req.called) done(); }); }) @@ -104,7 +104,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - should(req.called).be.true() + assert.ok(req.called) done(); }); }) @@ -130,7 +130,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - req.order.should.equal('abc'); + assert.strictEqual(req.order, 'abc') done(); }); }) @@ -156,9 +156,9 @@ describe('Route', function(){ }); route.dispatch(req, {}, function (err) { - should(err).be.ok() - should(err.message).equal('foobar'); - req.order.should.equal('a'); + assert.ok(err) + assert.strictEqual(err.message, 'foobar') + assert.strictEqual(req.order, 'a') done(); }); }) @@ -182,9 +182,9 @@ describe('Route', function(){ }); route.dispatch(req, {}, function (err) { - should(err).be.ok() - should(err.message).equal('foobar'); - req.order.should.equal('a'); + assert.ok(err) + assert.strictEqual(err.message, 'foobar') + assert.strictEqual(req.order, 'a') done(); }); }); @@ -208,7 +208,7 @@ describe('Route', function(){ route.dispatch(req, {}, function (err) { if (err) return done(err); - should(req.message).equal('oops'); + assert.strictEqual(req.message, 'oops') done(); }); }); @@ -222,8 +222,8 @@ describe('Route', function(){ }); route.dispatch(req, {}, function(err){ - should(err).be.ok() - err.message.should.equal('boom!'); + assert.ok(err) + assert.strictEqual(err.message, 'boom!') done(); }); }); @@ -234,7 +234,7 @@ describe('Route', function(){ route.all(function(err, req, res, next){ // this should not execute - true.should.be.false() + throw new Error('should not be called') }); route.dispatch(req, {}, done); diff --git a/test/exports.js b/test/exports.js index 98d79365..5ab0f885 100644 --- a/test/exports.js +++ b/test/exports.js @@ -3,11 +3,10 @@ var assert = require('assert') var express = require('../'); var request = require('supertest'); -var should = require('should'); describe('exports', function(){ it('should expose Router', function(){ - express.Router.should.be.a.Function() + assert.strictEqual(typeof express.Router, 'function') }) it('should expose json middleware', function () { @@ -36,20 +35,23 @@ describe('exports', function(){ }) it('should expose the application prototype', function(){ - express.application.set.should.be.a.Function() + assert.strictEqual(typeof express.application, 'object') + assert.strictEqual(typeof express.application.set, 'function') }) it('should expose the request prototype', function(){ - express.request.accepts.should.be.a.Function() + assert.strictEqual(typeof express.request, 'object') + assert.strictEqual(typeof express.request.accepts, 'function') }) it('should expose the response prototype', function(){ - express.response.send.should.be.a.Function() + assert.strictEqual(typeof express.response, 'object') + assert.strictEqual(typeof express.response.send, 'function') }) it('should permit modifying the .application prototype', function(){ express.application.foo = function(){ return 'bar'; }; - express().foo().should.equal('bar'); + assert.strictEqual(express().foo(), 'bar') }) it('should permit modifying the .request prototype', function(done){ @@ -79,10 +81,7 @@ describe('exports', function(){ }) it('should throw on old middlewares', function(){ - var error; - try { express.bodyParser; } catch (e) { error = e; } - should(error).have.property('message'); - error.message.should.containEql('middleware'); - error.message.should.containEql('bodyParser'); + assert.throws(function () { express.bodyParser() }, /Error:.*middleware.*bodyParser/) + assert.throws(function () { express.limit() }, /Error:.*middleware.*limit/) }) }) diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index 1e065ec5..00000000 --- a/test/mocha.opts +++ /dev/null @@ -1,2 +0,0 @@ ---require should ---slow 20 diff --git a/test/res.sendFile.js b/test/res.sendFile.js index c7fc93a7..c676fc41 100644 --- a/test/res.sendFile.js +++ b/test/res.sendFile.js @@ -7,7 +7,6 @@ var express = require('../') , assert = require('assert'); var onFinished = require('on-finished'); var path = require('path'); -var should = require('should'); var fixtures = path.join(__dirname, 'fixtures'); var utils = require('./support/utils'); @@ -359,15 +358,13 @@ describe('res', function(){ app.use(function (req, res) { res.sendFile(path.resolve(fixtures, 'does-not-exist'), function (err) { - should(err).be.ok() - err.status.should.equal(404); - res.send('got it'); + res.send(err ? 'got ' + err.status + ' error' : 'no error') }); }); request(app) - .get('/') - .expect(200, 'got it', done); + .get('/') + .expect(200, 'got 404 error', done) }) }) @@ -539,7 +536,7 @@ describe('res', function(){ app.use(function(req, res){ res.sendfile('test/fixtures/user.html', function(err){ assert(!res.headersSent); - req.socket.listeners('error').should.have.length(1); // node's original handler + assert.strictEqual(req.socket.listeners('error').length, 1) // node's original handler done(); }); @@ -783,12 +780,12 @@ describe('res', function(){ }); request(app) - .get('/') - .end(function(err, res){ - res.statusCode.should.equal(404); - calls.should.equal(1); - done(); - }); + .get('/') + .expect(404, function (err) { + if (err) return done(err) + assert.strictEqual(calls, 1) + done() + }) }) describe('with non-GET', function(){ diff --git a/test/utils.js b/test/utils.js index f0cb3c37..9a38ede6 100644 --- a/test/utils.js +++ b/test/utils.js @@ -2,7 +2,6 @@ var assert = require('assert'); var Buffer = require('safe-buffer').Buffer -var should = require('should') var utils = require('../lib/utils'); describe('utils.etag(body, encoding)', function(){ @@ -91,7 +90,14 @@ describe('utils.isAbsolute()', function(){ describe('utils.flatten(arr)', function(){ it('should flatten an array', function(){ var arr = ['one', ['two', ['three', 'four'], 'five']]; - should(utils.flatten(arr)) - .eql(['one', 'two', 'three', 'four', 'five']) + var flat = utils.flatten(arr) + + assert.strictEqual(flat.length, 5) + assert.strictEqual(flat[0], 'one') + assert.strictEqual(flat[1], 'two') + assert.strictEqual(flat[2], 'three') + assert.strictEqual(flat[3], 'four') + assert.strictEqual(flat[4], 'five') + assert.ok(flat.every(function (v) { return typeof v === 'string' })) }) })