app.routes.error.js
This file
Path
test/app.routes.error.js
62 lines · 1.5 KiB · JavaScript
Last changed by
fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
History of this fileTake it
The walk stopped after 200 commits: lines older than 2027b87 point at it.
fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1–2why, one step back1'use strict'2fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 3why, one step back3var assert = require('node:assert')fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 4–62why, one step back4var express = require('../')5 , request = require('supertest');67describe('app', function(){8 describe('.VERB()', function(){9 it('should not get invoked without error handler on error', function(done) {10 var app = express();1112 app.use(function(req, res, next){13 next(new Error('boom!'))14 });1516 app.get('/bar', function(req, res){17 res.send('hello, world!');18 });1920 request(app)21 .post('/bar')22 .expect(500, /Error: boom!/, done);23 });2425 it('should only call an error handling routing callback when an error is propagated', function(done){26 var app = express();2728 var a = false;29 var b = false;30 var c = false;31 var d = false;3233 app.get('/', function(req, res, next){34 next(new Error('fabricated error'));35 }, function(req, res, next) {36 a = true;37 next();38 }, function(err, req, res, next){39 b = true;40 assert.strictEqual(err.message, 'fabricated error')41 next(err);42 }, function(err, req, res, next){43 c = true;44 assert.strictEqual(err.message, 'fabricated error')45 next();46 }, function(err, req, res, next){47 d = true;48 next();49 }, function(req, res){50 assert.ok(!a)51 assert.ok(b)52 assert.ok(c)53 assert.ok(!d)54 res.sendStatus(204);55 });5657 request(app)58 .get('/')59 .expect(204, done);60 })61 })62})