Skip to content

Commit 10361e3

Browse files
JulusianCopilot
andcommitted
chore: fixup jest config for esm libs
Co-authored-by: Copilot <copilot@github.com>
1 parent 93878d5 commit 10361e3

12 files changed

Lines changed: 33 additions & 3 deletions

File tree

meteor/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const path = require('path')
33
const commonConfig = {
44
modulePaths: ['<rootDir>/node_modules/'],
55
moduleNameMapper: {
6+
'^@sofie-automation/shared-lib/dist/(.+)\.js$': '<rootDir>/../packages/shared-lib/src/$1',
7+
'^@sofie-automation/shared-lib/dist/(.+)$': '<rootDir>/../packages/shared-lib/src/$1',
68
// Ensure libraries that would match the extension rule are still resolved
79
'bignumber.js': 'bignumber.js',
810
// Drop file extensions in imports

packages/blueprints-integration/jest.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ module.exports = {
99
diagnostics: {
1010
ignoreCodes: [
1111
151002, // hybrid module kind (Node16/18/Next)
12+
2823, // Import attributes not supported in CJS mode (ts-jest forces CJS, emits require() anyway)
1213
],
1314
},
1415
},
1516
],
1617
},
1718
moduleNameMapper: {
19+
'^@sofie-automation/shared-lib/dist/(.+)$': '<rootDir>/../shared-lib/src/$1',
1820
'(.+)\\.js$': '$1',
1921
},
2022
testMatch: ['**/__tests__/**/*.spec.(ts|js)'],
21-
testPathIgnorePatterns: ['integrationTests'],
23+
testPathIgnorePatterns: ['integrationTests', 'dist'],
2224
testEnvironment: 'node',
2325
coverageThreshold: {
2426
global: {

packages/blueprints-integration/tsconfig.build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"resolveJsonModule": true,
1414
"types": ["node"],
1515
"composite": true,
16-
"module": "node20"
16+
"module": "node20",
17+
"esModuleInterop": true
1718
},
1819
"references": [
1920
{

packages/corelib/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ module.exports = {
99
diagnostics: {
1010
ignoreCodes: [
1111
151002, // hybrid module kind (Node16/18/Next)
12+
2823, // Import attributes not supported in CJS mode (ts-jest forces CJS, emits require() anyway)
1213
],
1314
},
1415
},
1516
],
1617
},
1718
moduleNameMapper: {
19+
'^@sofie-automation/shared-lib/dist/(.+)$': '<rootDir>/../shared-lib/src/$1',
1820
'(.+)\\.js$': '$1',
1921
},
2022
testMatch: ['**/__tests__/**/*.(spec|test).(ts|js)'],

packages/job-worker/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ module.exports = {
1717
6133, // Declared but not used
1818
6192, // All imports are unused
1919
151002, // hybrid module kind (Node16/18/Next)
20+
2823, // Import attributes not supported in CJS mode (ts-jest forces CJS, emits require() anyway)
2021
],
2122
},
2223
},
2324
],
2425
'^.+\\.(js|jsx|mjs)$': path.resolve('./scripts/babel-jest.mjs'),
2526
},
2627
moduleNameMapper: {
28+
'^@sofie-automation/shared-lib/dist/(.+)$': '<rootDir>/../shared-lib/src/$1',
2729
'(.+)\\.js$': '$1',
2830
},
2931
transformIgnorePatterns: ['node_modules/(?!(debounce-fn|p-queue|p-timeout)/)', '\\.pnp\\.[^\\/]+$'],

packages/live-status-gateway/jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ module.exports = {
99
diagnostics: {
1010
ignoreCodes: [
1111
151002, // hybrid module kind (Node16/18/Next)
12+
2823, // Import attributes not supported in CJS mode (ts-jest forces CJS, emits require() anyway)
1213
],
1314
},
1415
},
1516
],
1617
},
1718
moduleNameMapper: {
19+
// Jest is not happy with esm modules, we need to point it to the source files instead
20+
'^@sofie-automation/shared-lib/dist/(.+)\\.js$': '<rootDir>/../shared-lib/src/$1',
21+
'^@sofie-automation/shared-lib/dist/(.+)$': '<rootDir>/../shared-lib/src/$1',
22+
'^@sofie-automation/server-core-integration$': '<rootDir>/../server-core-integration/src/index.ts',
1823
'(.+)\\.js$': '$1',
1924
},
2025
testMatch: ['**/__tests__/**/*.(spec|test).(ts|js)'],

packages/meteor-lib/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ module.exports = {
99
diagnostics: {
1010
ignoreCodes: [
1111
151002, // hybrid module kind (Node16/18/Next)
12+
2823, // Import attributes not supported in CJS mode (ts-jest forces CJS, emits require() anyway)
1213
],
1314
},
1415
},
1516
],
1617
},
1718
moduleNameMapper: {
19+
'^@sofie-automation/shared-lib/dist/(.+)$': '<rootDir>/../shared-lib/src/$1',
1820
'(.+)\\.js$': '$1',
1921
},
2022
testMatch: ['**/__tests__/**/*.(spec|test).(ts|js)'],

packages/mos-gateway/jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ module.exports = {
99
diagnostics: {
1010
ignoreCodes: [
1111
151002, // hybrid module kind (Node16/18/Next)
12+
2823, // Import attributes not supported in CJS mode (ts-jest forces CJS, emits require() anyway)
1213
],
1314
},
1415
},
1516
],
1617
},
1718
moduleNameMapper: {
19+
// Jest is not happy with esm modules, we need to point it to the source files instead
20+
'^@sofie-automation/shared-lib/dist/(.+)\\.js$': '<rootDir>/../shared-lib/src/$1',
21+
'^@sofie-automation/shared-lib/dist/(.+)$': '<rootDir>/../shared-lib/src/$1',
22+
'^@sofie-automation/server-core-integration$': '<rootDir>/../server-core-integration/src/index.ts',
1823
'(.+)\\.js$': '$1',
1924
},
2025
testMatch: ['**/__tests__/**/*.(spec|test).(ts|js)'],

packages/server-core-integration/jest.config.js renamed to packages/server-core-integration/jest.config.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ module.exports = {
99
diagnostics: {
1010
ignoreCodes: [
1111
151002, // hybrid module kind (Node16/18/Next)
12+
2823, // Import attributes not supported in CJS mode (ts-jest forces CJS, emits require() anyway)
13+
7006, // Parameter implicitly has an 'any' type
14+
7016, // Some import errors with underscore
1215
],
1316
},
1417
},
1518
],
1619
},
1720
moduleNameMapper: {
21+
'^@sofie-automation/shared-lib/dist/(.+)\\.js$': '<rootDir>/../shared-lib/src/$1',
22+
'^@sofie-automation/shared-lib/dist/(.+)$': '<rootDir>/../shared-lib/src/$1',
1823
'(.+)\\.js$': '$1',
1924
},
2025
testMatch: ['**/__tests__/**/*.spec.(ts|js)'],

packages/server-core-integration/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"include": ["src/**/*.ts", "examples/*.ts", "package.json"],
55
"compilerOptions": {
66
"rootDir": "./",
7-
"types": ["jest", "node"]
7+
"types": ["jest", "node"],
8+
"verbatimModuleSyntax": false
89
}
910
}

0 commit comments

Comments
 (0)