Browse Source

Remove 404 routes

Express will auto 404 on missing routes
create-test-server
Luke Childs 7 years ago
parent
commit
33f035d204
  1. 6
      test/helpers.js
  2. 5
      test/http.js
  3. 8
      test/stream.js

6
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);

5
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 => {

8
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();

Loading…
Cancel
Save