diff --git a/package.json b/package.json index 12e9fb2..eb6df78 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "prettier": "prettier '**/*.+(js|json|ts|tsx|md|yml|yaml)'", "format": "yarn prettier --write", "check-format": "yarn prettier --list-different", - "test": "yarn workspaces run test", + "test": "yarn workspaces run test --passWithNoTests", "lint": "eslint --ignore-path .gitignore --ignore-pattern '**/esm/' .", "validate": "yarn lint && yarn check-types && yarn check-format" }, @@ -41,25 +41,5 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "typescript": "^5.1.3" - }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": ".", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "./coverage", - "testEnvironment": "node", - "roots": [ - "/packages/" - ] } } diff --git a/packages/client/jest.config.ts b/packages/client/jest.config.ts new file mode 100644 index 0000000..457d6c8 --- /dev/null +++ b/packages/client/jest.config.ts @@ -0,0 +1,24 @@ +import type { Config } from '@jest/types' + +const config: Config.InitialOptions = { + preset: 'ts-jest', + testEnvironment: 'node', + coveragePathIgnorePatterns: ['/build/', '/node_modules/', '/__tests__/', 'tests'], + coverageDirectory: '/coverage/', + testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'], + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + isolatedModules: true, + }, + ], + '^.+\\.jsx?$': require.resolve('babel-jest'), + }, + moduleNameMapper: { + // Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451 + uuid: require.resolve('uuid'), + }, +} + +export default config diff --git a/packages/server/jest.config.ts b/packages/server/jest.config.ts new file mode 100644 index 0000000..2569e4c --- /dev/null +++ b/packages/server/jest.config.ts @@ -0,0 +1,20 @@ +import type { Config } from '@jest/types' + +const config: Config.InitialOptions = { + preset: 'ts-jest', + testEnvironment: 'node', + coveragePathIgnorePatterns: ['/build/', '/node_modules/', '/__tests__/', 'tests'], + coverageDirectory: '/coverage/', + testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'], + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + isolatedModules: true, + }, + ], + }, + moduleNameMapper: { '^uuid$': 'uuid' }, +} + +export default config diff --git a/packages/server/package.json b/packages/server/package.json index 4cff1fd..e614ef1 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -69,26 +69,6 @@ "tsconfig-paths": "^4.2.0", "typescript": "^5.1.3" }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": ".", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "./coverage", - "testEnvironment": "node", - "roots": [ - "/packages/" - ] - }, "publishConfig": { "access": "restricted" }