From 33f035d20476d3dcc7546f0d14d48840baff792b Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sun, 8 Oct 2017 14:27:12 +0100 Subject: [PATCH] Remove 404 routes Express will auto 404 on missing routes --- test/helpers.js | 6 +----- test/http.js | 5 ----- test/stream.js | 8 ++------ 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/test/helpers.js b/test/helpers.js index f230cf9..2f8504a 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -10,17 +10,13 @@ test.before('setup', async () => { s.get('/', (req, res) => { res.send('ok'); }); - - s.get('/404', (req, res) => { - res.status(404).send('not found'); - }); }); test('promise mode', async t => { t.is((await got.get(s.url)).body, 'ok'); const err = await t.throws(got.get(`${s.url}/404`)); - t.is(err.response.body, 'not found'); + t.is(err.statusCode, 404); const err2 = await t.throws(got.get('.com', {retries: 0})); t.truthy(err2); diff --git a/test/http.js b/test/http.js index 399c4b6..fb2ef62 100644 --- a/test/http.js +++ b/test/http.js @@ -21,10 +21,6 @@ test.before('setup', async () => { s.get('/304', (req, res) => { res.status(304).end(); }); - - s.get('/404', (req, res) => { - res.status(404).end('not'); - }); }); test('simple request', async t => { @@ -47,7 +43,6 @@ test('requestUrl response', async t => { test('error with code', async t => { const err = await t.throws(got(`${s.url}/404`)); t.is(err.statusCode, 404); - t.is(err.response.body, 'not'); }); test('status code 304 doesn\'t throw', async t => { diff --git a/test/stream.js b/test/stream.js index 2ba3033..bb9254b 100644 --- a/test/stream.js +++ b/test/stream.js @@ -20,10 +20,6 @@ test.before('setup', async () => { s.get('/redirect', (req, res) => { res.redirect(302, s.url); }); - - s.get('/error', (req, res) => { - res.status(404).end(); - }); }); test('option.json can not be used', t => { @@ -83,12 +79,12 @@ test.cb('have response event', t => { }); test.cb('have error event', t => { - got.stream(`${s.url}/error`, {retries: 0}) + got.stream(`${s.url}/404`, {retries: 0}) .on('response', () => { t.fail('response event should not be emitted'); }) .on('error', (err, data, res) => { - t.is(err.message, 'Response code 404 (Not Found)'); + t.is(err.statusCode, 404); t.is(null, data); t.truthy(res); t.end();