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 d33aa0a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 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',
},
}
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',
},
}
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',
},
}

0 comments on commit d33aa0a

Please sign in to comment.