2019-05-28 07:04:44 -04:00
|
|
|
const chai = require('chai')
|
2019-11-18 09:37:05 -05:00
|
|
|
const sinon = require('sinon')
|
2019-05-28 07:04:44 -04:00
|
|
|
|
2020-05-22 06:34:57 -04:00
|
|
|
// add chai.should()
|
|
|
|
chai.should()
|
|
|
|
|
2019-05-28 07:04:44 -04:00
|
|
|
// Load sinon-chai assertions so expect(stubFn).to.have.been.calledWith('abc')
|
|
|
|
// has a nicer failure messages
|
|
|
|
chai.use(require('sinon-chai'))
|
2019-07-18 10:18:56 -04:00
|
|
|
|
2019-08-28 08:59:41 -04:00
|
|
|
// Load promise support for chai
|
|
|
|
chai.use(require('chai-as-promised'))
|
|
|
|
|
2019-10-07 04:30:51 -04:00
|
|
|
// Do not truncate assertion errors
|
|
|
|
chai.config.truncateThreshold = 0
|
|
|
|
|
2019-07-18 10:18:56 -04:00
|
|
|
// add support for mongoose in sinon
|
|
|
|
require('sinon-mongoose')
|
2019-11-07 05:28:27 -05:00
|
|
|
|
|
|
|
// Crash the process on an unhandled promise rejection
|
|
|
|
process.on('unhandledRejection', err => {
|
|
|
|
console.error('Unhandled promise rejection:', err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
2019-11-18 09:37:05 -05:00
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
sinon.restore()
|
|
|
|
})
|