Skip to content

Commit

Permalink
chore(tests): Convert jest config to js
Browse files Browse the repository at this point in the history
Which seems to speed up the tests execution.

hyperfine --warmup 5 --prepare "nx reset && nx clear-cache" \
                    --runs 100 "nx run-many -t lint"
  Time (mean ± σ):    1.417s ±  0.053s  [User: 0.887s, System: 0.113s]
  Range (min … max):  1.368s …  1.775s  100 runs

hyperfine --warmup 5 --prepare "nx reset && nx clear-cache" \
                    --runs 100 "nx run-many -t build"
  Time (mean ± σ):    2.110s ±  0.021s  [User: 2.571s, System: 0.216s]
  Range (min … max):  2.078s …  2.193s  100 runs

hyperfine --warmup 5 --prepare "nx reset && nx clear-cache" \
                    --runs 100 "nx run-many -t test"
  Time (mean ± σ):    1.493s ±  0.010s  [User: 0.787s, System: 0.134s]
  Range (min … max):  1.460s …  1.540s  100 runs
  • Loading branch information
roalcantara committed Jun 4, 2024
1 parent 7978236 commit e9515ca
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
25 changes: 25 additions & 0 deletions apps/app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
let jestConfigObject = {
displayName: 'app',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }]
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/app'
}

if (process.env.NODE_ENV === 'CI' || process.env.CI === 'true') {
jestConfigObject.transform = {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true,
diagnostics: false
}
]
}
}

module.exports = jestConfigObject
11 changes: 0 additions & 11 deletions apps/app/jest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/app/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"emitDecoratorMetadata": true,
"target": "es2021"
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"exclude": ["jest.config.js", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion apps/app/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"jest.config.js",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
Expand Down
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
process.env.TZ = 'UTC'

const { getJestProjectsAsync } = require('@nx/jest')

module.exports = {
projects: await getJestProjectsAsync()
}
5 changes: 0 additions & 5 deletions jest.config.ts

This file was deleted.

0 comments on commit e9515ca

Please sign in to comment.