Skip to content

Commit

Permalink
refactor jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbrugger committed Mar 29, 2024
1 parent 76eb343 commit dfa0d80
Show file tree
Hide file tree
Showing 25 changed files with 44 additions and 36 deletions.
22 changes: 9 additions & 13 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
const path = require('path')

module.exports = {
verbose: true,
testEnvironment: 'node',
testRegex: '.*\\.(e2e-)?spec\\.ts$',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
setupFiles: [path.join(__dirname, './testing/setup-tests.js')],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
setupFiles: ['<rootDir>/test/dotenv-config.ts'],
setupFilesAfterEnv: [
'<rootDir>/test/betterConsoleLog.ts',
'<rootDir>/test/unit.cleanup.ts',
],
testTimeout: 30_000,
globalSetup: './testing/setup-global.js',
globalSetup: '<rootDir>/test/setup-global.js',
forceExit: true,
}
2 changes: 1 addition & 1 deletion plugins/autocast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build": "rollup -c",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Alex Hollenbeck",
Expand Down
2 changes: 1 addition & 1 deletion plugins/automap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "parcel build",
"dev": "parcel watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Flatfile",
Expand Down
2 changes: 1 addition & 1 deletion plugins/constraints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"build:prod": "rollup -c --environment NODE_ENV:production",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "David Boskovic",
Expand Down
2 changes: 1 addition & 1 deletion plugins/dedupe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build": "rollup -c",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Flatfile, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion plugins/delimiter-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "parcel build",
"dev": "parcel watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Carl Brugger",
Expand Down
2 changes: 1 addition & 1 deletion plugins/dxp-configure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"build": "rollup -c",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "David Boskovic",
Expand Down
2 changes: 1 addition & 1 deletion plugins/job-handler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:prod": "rollup -c --environment NODE_ENV:production",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Flatfile, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion plugins/json-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build": "rollup -c",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Carl Brugger",
Expand Down
2 changes: 1 addition & 1 deletion plugins/json-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "parcel build",
"dev": "parcel watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Flatfile, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion plugins/openapi-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build": "rollup -c",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Flatfile, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion plugins/record-hook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"build:prod": "rollup -c --environment NODE_ENV:production",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Alex Hollenbeck",
Expand Down
2 changes: 1 addition & 1 deletion plugins/space-configure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build": "rollup -c",
"build:prod": "rollup -c --environment NODE_ENV:production",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Flatfile, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion plugins/webhook-egress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:prod": "rollup -c --environment NODE_ENV:production",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Flatfile, Inc.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
setupSpace,
} from '@flatfile/utils-testing'
import fetchMock from 'jest-fetch-mock'
import { webhookEventForward } from '../src'
import { webhookEventForward } from '.'

fetchMock.enableMocks()
fetchMock.dontMock()
Expand Down
2 changes: 1 addition & 1 deletion plugins/xlsx-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "parcel build",
"dev": "parcel watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "David Boskovic",
Expand Down
2 changes: 1 addition & 1 deletion plugins/xml-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "parcel build",
"dev": "parcel watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "David Boskovic",
Expand Down
2 changes: 1 addition & 1 deletion plugins/yaml-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "parcel build",
"dev": "parcel watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Flatfile, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion plugins/zip-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "parcel build",
"dev": "parcel watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"keywords": [],
"author": "Carl Brugger",
Expand Down
2 changes: 1 addition & 1 deletion support/common-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build": "parcel build",
"dev": "parcel watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions test/betterConsoleLog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
console.log = (...msgs) =>
msgs.forEach((msg) => process.stdout.write(msg + '\n'))
3 changes: 0 additions & 3 deletions testing/setup-tests.js → test/dotenv-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ const env = dotenv.config({
})

dotenvExpand.expand(env)

console.log = (...msgs) =>
msgs.forEach((msg) => process.stdout.write(msg + '\n'))
File renamed without changes.
13 changes: 13 additions & 0 deletions test/unit.cleanup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getHeapSpaceStatistics } from 'v8'

afterAll(() => {
// cleanup mocks and modules and allow the GC to do its thing:
jest.resetModules()
jest.clearAllMocks()
jest.clearAllTimers()
if (process.env['PRINT_V8_STATS'] === 'true') {
console.log(`${JSON.stringify(getHeapSpaceStatistics(), null, 4)}`)
}
})

export {}
2 changes: 1 addition & 1 deletion utils/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"build": "rollup -c",
"dev": "rollup -c --watch",
"check": "tsc ./**/*.ts --noEmit --esModuleInterop",
"test": "jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
"test": "TZ=UTC jest ./**/*.spec.ts --config=../../jest.config.js --runInBand"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit dfa0d80

Please sign in to comment.