overleaf/services/web/test/unit/bootstrap.js
Shane Kilkelly cbf08c599b Merge pull request #2333 from overleaf/em-unhandled-rejections
Fail tests on unhandled promise rejection

GitOrigin-RevId: 3cc53ce5b46c63c62374eb83f9442b8d6979272e
2019-11-07 10:48:36 +00:00

23 lines
635 B
JavaScript

const chai = require('chai')
require('sinon')
// Load sinon-chai assertions so expect(stubFn).to.have.been.calledWith('abc')
// has a nicer failure messages
chai.use(require('sinon-chai'))
// Load promise support for chai
chai.use(require('chai-as-promised'))
// Do not truncate assertion errors
chai.config.truncateThreshold = 0
// add support for promises in sinon
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)
})