Skip to content

Commit

Permalink
chore(repo): split internal and user-facing jest config (#4666)
Browse files Browse the repository at this point in the history
this commit separates stencil's internal testing jest configuration
(used when running unit tests on the stencil project itself), and the
jest configuration used by stencil projects (when a stencil user runs
`npm t` in their project).

with this commit, we remove the inheritance on the jest configuration
that we bundle with stencil for end users. in order to ensure that
stencil's internal tests continue to function, the internal jest config
has been updated to have near parity with the external one. the intent
of this commit is _not_ to optimize the jest config, but rather separate
the two so that we can begin to bring support for newer versions of jest
to end users without dragging out the process (i.e. upgrading ourselves)
  • Loading branch information
rwaskiewicz authored Aug 14, 2023
1 parent 664ecb7 commit a81c0d5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
preset: './testing/jest-preset.js',
moduleNameMapper: {
'@app-data': '<rootDir>/internal/app-data/index.cjs',
'@app-globals': '<rootDir>/internal/app-globals/index.cjs',
Expand All @@ -12,6 +11,8 @@ module.exports = {
'@sys-api-node': '<rootDir>/sys/node/index.js',
'@utils': '<rootDir>/src/utils',
'^typescript$': '<rootDir>/scripts/build/typescript-modified-for-jest.js',
'^@stencil/core/internal/app-data$': '<rootDir>/internal/app-data/index.cjs',
'^@stencil/core/internal/testing$': '<rootDir>/internal/testing/index.js',
},
coverageDirectory: './coverage/',
coverageReporters: ['json', 'lcov', 'text', 'clover'],
Expand All @@ -36,7 +37,10 @@ module.exports = {
'<rootDir>/src/testing/**/*.{js,jsx,ts,tsx}',
'<rootDir>/src/utils/**/*.{js,jsx,ts,tsx}',
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'mjs', 'jsx', 'json', 'd.ts'],
modulePathIgnorePatterns: ['/bin', '/www'],
setupFilesAfterEnv: ['<rootDir>/testing/jest-setuptestframework.js'],
testEnvironment: '<rootDir>/testing/jest-environment.js',
testPathIgnorePatterns: [
'<rootDir>/.cache/',
'<rootDir>/.github/',
Expand All @@ -57,7 +61,10 @@ module.exports = {
'<rootDir>/testing/',
],
testRegex: '/(src|scripts)/.*\\.spec\\.(ts|tsx|js)$',
// TODO(STENCIL-307): Move away from Jasmine runner for internal Stencil tests, which involves re-working environment
// setup
// TODO(STENCIL-307): Move away from Jasmine runner for internal Stencil tests as a part of the (internal) Jest 28+ upgrade
testRunner: 'jest-jasmine2',
transform: {
'^.+\\.(ts|tsx|jsx|css|mjs)$': '<rootDir>/testing/jest-preprocessor.js',
},
watchPathIgnorePatterns: ['^.+\\.d\\.ts$'],
};

0 comments on commit a81c0d5

Please sign in to comment.