Skip to content

Commit

Permalink
test: Update to tap v14
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoltman committed Jun 16, 2019
1 parent 5d87bc4 commit c41dd34
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 40 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"send": "^0.17.1",
"simple-get": "^3.0.3",
"streaming-json-stringify": "^3.1.0",
"tap": "^12.1.1",
"tap": "^14.2.3",
"then-sleep": "^1.0.1"
},
"pre-commit": [
Expand All @@ -62,8 +62,8 @@
"benchmark": "concurrently -k -s first \"node ./benchmarks/basic.js\" \"npm run cannon\"",
"cannon": "autocannon -c 100 -d 5 -p 10 localhost:3000/",
"lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ignore-pattern coverage .",
"test": "tap -J test/*.test.js test/*/*.test.js",
"coverage": "npm run test -- --cov --coverage-report=html",
"test": "tap -J --reporter=classic --no-coverage --no-esm test/*.test.js test/*/*.test.js",
"coverage": "npm run test -- --cov --coverage-report=text --coverage-report=html --no-browser",
"coveralls": "npm run test -- -j4 -c --cov --100",
"ci": "npm run lint && npm run coveralls",
"bumpMinor": "npm version minor -m \"v%s\""
Expand Down
24 changes: 11 additions & 13 deletions test/system-errors/errorHandler-throws.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

const t = require('tap')
const medley = require('../..')
const app = medley()

let errored = false
t.plan(1)

process.removeAllListeners('unhandledRejection')

process.on('unhandledRejection', (err) => {
t.equal(err.message, 'kaboom')
})

const app = medley()

app.route({
method: 'GET',
Expand All @@ -14,23 +21,14 @@ app.route({
},
})

app.setErrorHandler((_, req, res) => {
return Promise.resolve().then(() => res.send())
app.setErrorHandler(async (_, req, res) => { // eslint-disable-line require-await
res.send()
})

app.addHook('onSend', () => {
throw new Error('kaboom')
})

process.on('unhandledRejection', (err) => {
errored = true
t.equal(err.message, 'kaboom')
})

app.inject('/', () => {
t.fail('should not be called')
})

process.on('beforeExit', () => {
t.ok(errored)
})
20 changes: 9 additions & 11 deletions test/system-errors/handler-throws.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

const t = require('tap')
const medley = require('../..')
const app = medley()

let errored = false
t.plan(1)

process.removeAllListeners('uncaughtException')

process.on('uncaughtException', (err) => {
t.equal(err.message, 'kaboom')
})

const app = medley()

app.route({
method: 'GET',
Expand All @@ -14,15 +21,6 @@ app.route({
},
})

process.on('uncaughtException', (err) => {
errored = true
t.equal(err.message, 'kaboom')
})

app.inject('/', () => {
t.fail('should not be called')
})

process.on('beforeExit', () => {
t.ok(errored)
})
24 changes: 11 additions & 13 deletions test/system-errors/onSend-throws.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,29 @@

const t = require('tap')
const medley = require('../..')
const app = medley()

let errored = false
t.plan(1)

process.removeAllListeners('unhandledRejection')

process.on('unhandledRejection', (err) => {
t.equal(err.message, 'kaboom')
})

const app = medley()

app.route({
method: 'GET',
path: '/',
handler(req, res) {
return Promise.resolve().then(() => res.send())
async handler(req, res) { // eslint-disable-line require-await
res.send()
},
})

app.addHook('onSend', () => {
throw new Error('kaboom')
})

process.on('unhandledRejection', (err) => {
errored = true
t.equal(err.message, 'kaboom')
})

app.inject('/', () => {
t.fail('should not be called')
})

process.on('beforeExit', () => {
t.ok(errored)
})

0 comments on commit c41dd34

Please sign in to comment.