Skip to content

Commit

Permalink
*: add forceExit flag to jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tilacog committed Jun 20, 2023
1 parent 1232c60 commit a1ac1ab
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 28 deletions.
7 changes: 5 additions & 2 deletions packages/indexer-agent/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const bail = (s) => {
const bail = s => {
throw new Error(s)
}

module.exports = {
collectCoverage: true,
forceExit: true,
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/dist/', '.yalc'],
globals: {
__DATABASE__: {
host: process.env.POSTGRES_TEST_HOST || bail('POSTGRES_TEST_HOST is not defined'),
host:
process.env.POSTGRES_TEST_HOST ||
bail('POSTGRES_TEST_HOST is not defined'),
port: parseInt(process.env.POSTGRES_TEST_PORT || '5432'),
username:
process.env.POSTGRES_TEST_USERNAME ||
Expand Down
17 changes: 9 additions & 8 deletions packages/indexer-cli/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const bail = (s) => {
const bail = s => {
throw new Error(s)
}

module.exports = {
collectCoverage: false,
preset: 'ts-jest',
forceExit: true,
testEnvironment: 'node',
// The glob patterns Jest uses to detect test files
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
Expand All @@ -15,15 +16,15 @@ module.exports = {
host: process.env.POSTGRES_TEST_HOST || bail('POSTGRES_TEST_HOST is not defined'),
port: parseInt(process.env.POSTGRES_TEST_PORT || '5432'),
username:
process.env.POSTGRES_TEST_USERNAME ||
bail('POSTGRES_TEST_USERNAME is not defined'),
process.env.POSTGRES_TEST_USERNAME ||
bail('POSTGRES_TEST_USERNAME is not defined'),
password:
process.env.POSTGRES_TEST_PASSWORD ||
bail('POSTGRES_TEST_PASSWORD is not defined'),
process.env.POSTGRES_TEST_PASSWORD ||
bail('POSTGRES_TEST_PASSWORD is not defined'),
database:
process.env.POSTGRES_TEST_DATABASE ||
bail('POSTGRES_TEST_DATABASE is not defined'),
process.env.POSTGRES_TEST_DATABASE ||
bail('POSTGRES_TEST_DATABASE is not defined'),
},
__LOG_LEVEL__: process.env.LOG_LEVEL || 'info'
__LOG_LEVEL__: process.env.LOG_LEVEL || 'info',
},
}
2 changes: 1 addition & 1 deletion packages/indexer-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"clean": "rm -rf ./node_modules ./dist ./tsconfig.tsbuildinfo",
"test": "jest --colors --verbose --runInBand --detectOpenHandles",
"test:ci": "LOG_LEVEL=error jest --verbose --runInBand --ci",
"test:debug": "LOG_LEVEL=debug jest --runInBand --detectOpenHandles --verbose --forceExit",
"test:debug": "LOG_LEVEL=debug jest --runInBand --detectOpenHandles --verbose",
"test:watch": "jest --watch --detectOpenHandles --verbose"
},
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions packages/indexer-common/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const bail = (s) => {
module.exports = {
collectCoverage: true,
preset: 'ts-jest',
forceExit: true,
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/.yalc', 'util.ts'],
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/.yalc', 'util.ts'],
globals: {
__DATABASE__: {
host: process.env.POSTGRES_TEST_HOST || bail('POSTGRES_TEST_HOST is not defined'),
Expand All @@ -21,6 +22,6 @@ module.exports = {
process.env.POSTGRES_TEST_DATABASE ||
bail('POSTGRES_TEST_DATABASE is not defined'),
},
__LOG_LEVEL__: process.env.LOG_LEVEL || 'info'
__LOG_LEVEL__: process.env.LOG_LEVEL || 'info',
},
}
6 changes: 3 additions & 3 deletions packages/indexer-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"lint": "eslint . --ext .ts,.tsx --fix",
"compile": "tsc",
"prepare": "yarn format && yarn lint && yarn compile",
"test": "LOG_LEVEL=info jest --colors --verbose --forceExit --runInBand --detectOpenHandles",
"test:ci": "LOG_LEVEL=error jest --verbose --runInBand --forceExit --ci",
"test:debug": "LOG_LEVEL=debug jest --runInBand --detectOpenHandles --verbose --forceExit",
"test": "LOG_LEVEL=info jest --colors --verbose --runInBand --detectOpenHandles",
"test:ci": "LOG_LEVEL=error jest --verbose --runInBand --ci",
"test:debug": "LOG_LEVEL=debug jest --runInBand --detectOpenHandles --verbose",
"test:watch": "jest --runInBand --detectOpenHandles --watch --passWithNoTests --verbose",
"clean": "rm -rf ./node_modules ./dist ./tsconfig.tsbuildinfo"
},
Expand Down
1 change: 1 addition & 0 deletions packages/indexer-native/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
forceExit: true,
collectCoverage: true,
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/dist/', '.yalc']
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"lint": "eslint .",
"prepare": "yarn format && yarn lint",
"install": "yarn pull-or-build",
"test": "jest --colors --verbose --forceExit",
"test": "jest --colors --verbose",
"test:ci": "jest --verbose --ci",
"clean": "rm -rf ./node_modules ./binary ./build ./coverage ./native/target ./native/artifacts.json ./native/index.node"
},
Expand Down
19 changes: 10 additions & 9 deletions packages/indexer-service/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
const bail = (s) => {
const bail = s => {
throw new Error(s)
}

module.exports = {
collectCoverage: true,
forceExit: true,
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/dist/', '.yalc'],
globals: {
"ts-jest": {
'ts-jest': {
isolatedModules: true,
},
__DATABASE__: {
host: process.env.POSTGRES_TEST_HOST || bail('POSTGRES_TEST_HOST is not defined'),
port: parseInt(process.env.POSTGRES_TEST_PORT || '5432'),
username:
process.env.POSTGRES_TEST_USERNAME ||
bail('POSTGRES_TEST_USERNAME is not defined'),
process.env.POSTGRES_TEST_USERNAME ||
bail('POSTGRES_TEST_USERNAME is not defined'),
password:
process.env.POSTGRES_TEST_PASSWORD ||
bail('POSTGRES_TEST_PASSWORD is not defined'),
process.env.POSTGRES_TEST_PASSWORD ||
bail('POSTGRES_TEST_PASSWORD is not defined'),
database:
process.env.POSTGRES_TEST_DATABASE ||
bail('POSTGRES_TEST_DATABASE is not defined'),
process.env.POSTGRES_TEST_DATABASE ||
bail('POSTGRES_TEST_DATABASE is not defined'),
},
__LOG_LEVEL__: process.env.LOG_LEVEL || 'info'
__LOG_LEVEL__: process.env.LOG_LEVEL || 'info',
},
}
4 changes: 2 additions & 2 deletions packages/indexer-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"compile": "tsc --build",
"prepare": "yarn format && yarn lint && yarn compile",
"start": "node ./dist/index.js start",
"test": "jest --colors --verbose --forceExit --detectOpenHandles",
"test:ci": "jest --verbose --forceExit --ci",
"test": "jest --colors --verbose --detectOpenHandles",
"test:ci": "jest --verbose --ci",
"test:watch": "jest --watch --passWithNoTests --detectOpenHandles --verbose",
"clean": "rm -rf ./node_modules ./dist ./tsconfig.tsbuildinfo"
},
Expand Down

0 comments on commit a1ac1ab

Please sign in to comment.