-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: rework unit tests to separate dom and node tests (#1276)
## Proposed change Currently, we only have 1 jest config for all unit-tests Unfortunately, the tests for `src` usually don't require the same environment as the tests for `schematics` and `builders` The idea is to have a different project for each (check `packages/@o3r/core/jest.config.ts`) This will fix the tests issue on #1255 and #1243 ## Related issues - 🐛 Fixes #(issue) - 🚀 Feature #(issue) <!-- Please make sure to follow the contributing guidelines on https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md -->
- Loading branch information
Showing
235 changed files
with
1,717 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
const getJestConfig = require('../../jest.config.ut').getJestConfig; | ||
const getJestGlobalConfig = require('../../jest.config.ut').getJestGlobalConfig; | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestConfig(__dirname, true), | ||
displayName: require('./package.json').name, | ||
transformIgnorePatterns: ['^.+\\.js$'], | ||
globals: { | ||
chrome: { | ||
runtime: {}, | ||
devtools: { | ||
inspectedWindow: {} | ||
} | ||
} | ||
} | ||
...getJestGlobalConfig(), | ||
projects: [ | ||
'<rootDir>/testing/jest.config.ut.js' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const path = require('node:path'); | ||
const getJestProjectConfig = require('../../../jest.config.ut').getJestProjectConfig; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestProjectConfig(rootDir, true), | ||
displayName: require('../package.json').name, | ||
rootDir, | ||
transformIgnorePatterns: ['^.+\\.js$'], | ||
globals: { | ||
chrome: { | ||
runtime: {}, | ||
devtools: { | ||
inspectedWindow: {} | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
const getJestConfig = require('../../jest.config.ut').getJestConfig; | ||
const getJestGlobalConfig = require('../../jest.config.ut').getJestGlobalConfig; | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestConfig(__dirname, true), | ||
displayName: require('./package.json').name | ||
...getJestGlobalConfig(), | ||
projects: [ | ||
'<rootDir>/testing/jest.config.ut.js' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const path = require('node:path'); | ||
const getJestProjectConfig = require('../../../jest.config.ut').getJestProjectConfig; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestProjectConfig(rootDir, true), | ||
displayName: require('../package.json').name, | ||
rootDir | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
const getJestConfig = require('../../jest.config.ut').getJestConfig; | ||
const getJestGlobalConfig = require('../../jest.config.ut').getJestGlobalConfig; | ||
|
||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestConfig(__dirname, true), | ||
displayName: require('./package.json').name | ||
...getJestGlobalConfig(), | ||
projects: [ | ||
'<rootDir>/testing/jest.config.ut.js' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const path = require('node:path'); | ||
const getJestProjectConfig = require('../../../jest.config.ut').getJestProjectConfig; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestProjectConfig(rootDir, true), | ||
displayName: require('../package.json').name, | ||
rootDir | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
const getJestConfig = require('../../jest.config.ut').getJestConfig; | ||
const getJestGlobalConfig = require('../../jest.config.ut').getJestGlobalConfig; | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestConfig(__dirname, false), | ||
displayName: require('./package.json').name, | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/dist', | ||
'<rootDir>/.*/templates/.*', | ||
'\\.it\\.spec\\.ts$' | ||
...getJestGlobalConfig(), | ||
projects: [ | ||
'<rootDir>/testing/jest.config.ut.js' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const path = require('node:path'); | ||
const getJestProjectConfig = require('../../../jest.config.ut').getJestProjectConfig; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestProjectConfig(rootDir, false), | ||
displayName: require('../package.json').name, | ||
rootDir | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
const getJestConfig = require('../../../jest.config.ut').getJestConfig; | ||
const getJestGlobalConfig = require('../../../jest.config.ut').getJestGlobalConfig; | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestConfig(__dirname, false), | ||
displayName: require('./package.json').name, | ||
fakeTimers: { | ||
enableGlobally: true, | ||
// TODO try to make date utils work with fake Date | ||
doNotFake: ['Date'] | ||
} | ||
...getJestGlobalConfig(), | ||
projects: [ | ||
'<rootDir>/testing/jest.config.ut.js', | ||
'<rootDir>/testing/jest.config.ut.builders.js' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const path = require('node:path'); | ||
const getJestProjectConfig = require('../../../../jest.config.ut').getJestProjectConfig; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestProjectConfig(rootDir, false), | ||
displayName: `${require('../package.json').name}/builders`, | ||
rootDir, | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/.*/templates/.*', | ||
'<rootDir>/src/.*', | ||
'\\.it\\.spec\\.ts$' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const path = require('node:path'); | ||
const getJestProjectConfig = require('../../../../jest.config.ut').getJestProjectConfig; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestProjectConfig(rootDir, false), | ||
displayName: require('../package.json').name, | ||
rootDir, | ||
fakeTimers: { | ||
enableGlobally: true, | ||
// TODO re-enable fake dates when issue fixed https://github.com/sinonjs/fake-timers/issues/437 | ||
doNotFake: ['Date'] | ||
}, | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/.*/templates/.*', | ||
'<rootDir>/builders/.*', | ||
'<rootDir>/schematics/.*', | ||
'\\.it\\.spec\\.ts$' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
import 'isomorphic-fetch'; | ||
import '@o3r/test-helpers/setup-jest-builders'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
const getJestConfig = require('../../../jest.config.ut').getJestConfig; | ||
const getJestGlobalConfig = require('../../../jest.config.ut').getJestGlobalConfig; | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestConfig(__dirname, false), | ||
displayName: require('./package.json').name, | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/.*/templates/.*', | ||
'\\.it\\.spec\\.ts$' | ||
], | ||
testTimeout: 30 * 1000 | ||
...getJestGlobalConfig(), | ||
projects: [ | ||
'<rootDir>/testing/jest.config.ut.js', | ||
'<rootDir>/testing/jest.config.ut.builders.js' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/@ama-sdk/schematics/testing/jest.config.ut.builders.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const path = require('node:path'); | ||
const getJestProjectConfig = require('../../../../jest.config.ut').getJestProjectConfig; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestProjectConfig(rootDir, false), | ||
displayName: `${require('../package.json').name}/builders`, | ||
rootDir, | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/.*/templates/.*', | ||
'<rootDir>/src/.*', | ||
'\\.it\\.spec\\.ts$' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const path = require('node:path'); | ||
const getJestProjectConfig = require('../../../../jest.config.ut').getJestProjectConfig; | ||
const rootDir = path.join(__dirname, '..'); | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestProjectConfig(rootDir, false), | ||
displayName: require('../package.json').name, | ||
rootDir, | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/.*/templates/.*', | ||
'<rootDir>/builders/.*', | ||
'<rootDir>/schematics/.*', | ||
'\\.it\\.spec\\.ts$' | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import 'isomorphic-fetch'; | ||
import '@o3r/test-helpers/setup-jest-builders'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
const { getJestConfig } = require('../../../jest.config.ut'); | ||
const getJestGlobalConfig = require('../../../jest.config.ut').getJestGlobalConfig; | ||
|
||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
...getJestConfig(__dirname, false), | ||
displayName: require('./package.json').name, | ||
setupFilesAfterEnv: null, | ||
moduleNameMapper: { | ||
'^@ama-sdk/showcase-sdk$': ['<rootDir>/dist/cjs', '<rootDir>/src'], | ||
'^@ama-sdk/showcase-sdk/(.*)$': ['<rootDir>/dist/cjs/$1', '<rootDir>/src/$1'], | ||
} | ||
...getJestGlobalConfig(), | ||
projects: [ | ||
'<rootDir>/testing/jest.config.ut.js' | ||
] | ||
}; |
Oops, something went wrong.