Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikSerafin committed Mar 19, 2021
1 parent 7fa44eb commit 96248f8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/mailserver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ describe('mailserver', function () {
describe('smtp error handling', function () {
it('Error should be thrown, because listening to server did not work', function (done) {
const server = http.createServer(() => {})
server.listen(9025, '0.0.0.0')
const maildev = new MailDev({
disableWeb: true,
silent: true,
smtp: 9025
})
server.listen(9025, '0.0.0.0')
maildev.listen()
maildev.smtp.on('error', (err) => {

// https://stackoverflow.com/a/9132271/3143704

var originalHandler = process.listeners('uncaughtException').pop()
process.removeListener('uncaughtException', originalHandler)

process.once('uncaughtException', function (err) {
assert.strictEqual(err.code, 'EADDRINUSE')
process.listeners('uncaughtException').push(originalHandler)
maildev.close(() => server.close(done))
})
})
Expand Down

0 comments on commit 96248f8

Please sign in to comment.