Skip to content

Commit

Permalink
fix(test): fix rewiring with jest (#250)
Browse files Browse the repository at this point in the history
* fix(test): fix rewiring with jest

* test

* test 2

* remove unnecessary baseUrl

* simpler solution

* yarn silent

* test 3

* clean solution
  • Loading branch information
laurentlp committed Nov 23, 2021
1 parent fa5bb3d commit 32c2679
Show file tree
Hide file tree
Showing 4 changed files with 414 additions and 349 deletions.
11 changes: 10 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Config } from '@jest/types'
import { defaults as tsjPreset } from 'ts-jest/presets'
import { pathsToModuleNameMapper } from 'ts-jest/utils'

const ServerConfig = require('./packages/server/tsconfig.test.json')

const config: Config.InitialOptions = {
preset: 'ts-jest',
Expand Down Expand Up @@ -32,7 +35,13 @@ const config: Config.InitialOptions = {
transform: {
...tsjPreset.transform
},
clearMocks: true
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.test.json'
}
},
clearMocks: true,
moduleNameMapper: pathsToModuleNameMapper(ServerConfig.compilerOptions.paths, { prefix: '<rootDir>/' })
},
{
rootDir: 'packages/socket',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"start": "yarn workspace @botpress/messaging-server start",
"dev": "yarn workspace @botpress/messaging-server dev",
"board": "yarn workspace @botpress/messaging-board dev",
"test": "yarn workspace @botpress/messaging-server build && jest --selectProjects Engine Server Components"
"test": "yarn --silent && jest --selectProjects Engine Server Components"
},
"bin": "./packages/server/dist/index.js",
"pkg": {
Expand All @@ -32,7 +32,7 @@
"outputPath": "./bin"
},
"devDependencies": {
"@types/jest": "^27.0.1",
"@types/jest": "^27.0.3",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"conventional-changelog": "^3.1.24",
Expand All @@ -42,13 +42,13 @@
"eslint-plugin-import": "^2.24.1",
"eslint-plugin-jsdoc": "35.5.1",
"fs-extra": "^10.0.0",
"jest": "^27.0.6",
"jest": "^27.3.1",
"parcel": "1.12.3",
"pkg": "^4.5.1",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"ts-jest": "^27.0.5",
"ts-jest": "^27.0.7",
"ts-node-dev": "^1.1.8",
"typescript": "^4.3.5",
"yargs": "^17.1.1"
Expand Down
9 changes: 9 additions & 0 deletions packages/server/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {
"@botpress/messaging-base": ["../base/src/index.ts"],
"@botpress/messaging-engine": ["../engine/src/index.ts"]
}
}
}

0 comments on commit 32c2679

Please sign in to comment.