Просмотр исходного кода

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

Treat unhandled promise rejections as errors in tests

GitOrigin-RevId: ba9d8fa02e0687c6b2d1d95e495fe0b54bb0cff5
Simon Detheridge 6 лет назад
Родитель
Сommit
29f09c50c2

+ 7 - 0
services/web/docker-compose.ci.yml

@@ -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

+ 5 - 0
services/web/docker-compose.yml

@@ -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
 

+ 0 - 6
services/web/test/acceptance/bootstrap.js

@@ -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)
-})

+ 0 - 6
services/web/test/unit/bootstrap.js

@@ -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()
 })