Merge pull request #3071 from overleaf/spd-unhandled-promises-in-tests

Treat unhandled promise rejections as errors in tests

GitOrigin-RevId: ba9d8fa02e0687c6b2d1d95e495fe0b54bb0cff5
This commit is contained in:
Simon Detheridge 2020-08-11 13:20:23 +01:00 committed by Copybot
parent 2e8f66ac6b
commit 29f09c50c2
4 changed files with 12 additions and 12 deletions

View file

@ -10,6 +10,8 @@ services:
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
user: node
command: npm run test:unit:app
environment:
NODE_OPTIONS: "--unhandled-rejections=strict"
test_acceptance:
build: .
@ -25,6 +27,7 @@ services:
LINKED_URL_PROXY: 'http://localhost:6543'
LOCK_MANAGER_MAX_LOCK_WAIT_TIME: 30000
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
SHARELATEX_CONFIG:
command: npm run test:acceptance:app
user: root
@ -43,12 +46,16 @@ services:
working_dir: /app
command: npm run test:karma:single
user: node
environment:
NODE_OPTIONS: "--unhandled-rejections=strict"
test_frontend:
build: .
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
user: node
command: npm run test:frontend
environment:
NODE_OPTIONS: "--unhandled-rejections=strict"
tar:
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER-webpack

View file

@ -14,6 +14,7 @@ services:
working_dir: /app
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_OPTIONS: "--unhandled-rejections=strict"
command: npm run --silent test:unit:app
user: node
@ -32,6 +33,7 @@ services:
ENABLED_LINKED_FILE_TYPES: 'url,project_file,project_output_file,mendeley,zotero'
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
LOCK_MANAGER_MAX_LOCK_WAIT_TIME: 30000
MONGO_SOCKET_TIMEOUT: 60000
# SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING: 'true'
@ -47,6 +49,8 @@ services:
dockerfile: Dockerfile.frontend
volumes:
- .:/app
environment:
NODE_OPTIONS: "--unhandled-rejections=strict"
working_dir: /app
command: npm run --silent test:karma:single
@ -59,6 +63,7 @@ services:
working_dir: /app
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_OPTIONS: "--unhandled-rejections=strict"
command: npm run --silent test:frontend
user: node

View file

@ -4,9 +4,3 @@ chai.use(require('chaid'))
// Do not truncate assertion errors
chai.config.truncateThreshold = 0
// Crash the process on an unhandled promise rejection
process.on('unhandledRejection', err => {
console.error('Unhandled promise rejection:', err)
process.exit(1)
})

View file

@ -17,12 +17,6 @@ chai.config.truncateThreshold = 0
// 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)
})
afterEach(function() {
sinon.restore()
})