mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2333 from overleaf/em-unhandled-rejections
Fail tests on unhandled promise rejection GitOrigin-RevId: 3cc53ce5b46c63c62374eb83f9442b8d6979272e
This commit is contained in:
parent
cfaab43b08
commit
cbf08c599b
4 changed files with 22 additions and 3 deletions
6
services/web/test/acceptance/bootstrap.js
vendored
6
services/web/test/acceptance/bootstrap.js
vendored
|
@ -1,3 +1,9 @@
|
|||
const chai = require('chai')
|
||||
chai.use(require('chai-as-promised'))
|
||||
chai.use(require('chaid'))
|
||||
|
||||
// Crash the process on an unhandled promise rejection
|
||||
process.on('unhandledRejection', err => {
|
||||
console.error('Unhandled promise rejection:', err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
|
6
services/web/test/unit/bootstrap.js
vendored
6
services/web/test/unit/bootstrap.js
vendored
|
@ -15,3 +15,9 @@ chai.config.truncateThreshold = 0
|
|||
require('sinon-as-promised')
|
||||
// add support for mongoose in sinon
|
||||
require('sinon-mongoose')
|
||||
|
||||
// Crash the process on an unhandled promise rejection
|
||||
process.on('unhandledRejection', err => {
|
||||
console.error('Unhandled promise rejection:', err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
|
|
@ -72,8 +72,8 @@ describe('EmailSender', function() {
|
|||
|
||||
it('should return a non-specific error', async function() {
|
||||
this.sesClient.sendMail.rejects(new Error('boom'))
|
||||
expect(this.EmailSender.promises.sendEmail({})).to.be.rejectedWith(
|
||||
'Error: Cannot send email'
|
||||
await expect(this.EmailSender.promises.sendEmail({})).to.be.rejectedWith(
|
||||
'error sending message'
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
@ -33,6 +33,12 @@ describe('SAMLIdentityManager', function() {
|
|||
this.institution = {
|
||||
name: 'Overleaf University'
|
||||
}
|
||||
this.InstitutionsAPI = {
|
||||
promises: {
|
||||
addEntitlement: sinon.stub().resolves(),
|
||||
removeEntitlement: sinon.stub().resolves()
|
||||
}
|
||||
}
|
||||
this.SAMLIdentityManager = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
'../Email/EmailHandler': (this.EmailHandler = {
|
||||
|
@ -59,7 +65,8 @@ describe('SAMLIdentityManager', function() {
|
|||
}),
|
||||
'../User/UserUpdater': (this.UserUpdater = {
|
||||
addEmailAddress: sinon.stub()
|
||||
})
|
||||
}),
|
||||
'../Institutions/InstitutionsAPI': this.InstitutionsAPI
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue