Skip to content

Commit

Permalink
improve run time of jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvogt committed Jul 18, 2023
1 parent fffdd02 commit 810400c
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 26 deletions.
16 changes: 0 additions & 16 deletions frontend/.babelrc.json

This file was deleted.

36 changes: 36 additions & 0 deletions frontend/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
chrome: 100,
},
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
// Devs tend to write `import { someIcon } from '@patternfly/react-icons';`
// This transforms the import to be specific which prevents having to parse 2k+ icons
// Also prevents potential bundle size blowups with CJS
[
'transform-imports',
{
'@patternfly/react-icons': {
transform: (importName) =>
`@patternfly/react-icons/dist/js/icons/${
importName === 'PathMissingIcon'
? 'pathMissing-icon'
: importName
.split(/(?=[A-Z])/)
.join('-')
.toLowerCase()
}`,
preventFullImport: true,
},
},
],
],
};
16 changes: 8 additions & 8 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// https://jestjs.io/docs/en/configuration.html

module.exports = {
testMatch: ['**/__tests__/unit/**/*.ts'],
roots: ['<rootDir>/src/__tests__/unit'],
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],

// Automatically clear mock calls and instances between every test
clearMocks: true,
Expand All @@ -18,16 +19,15 @@ module.exports = {
'~/(.*)': '<rootDir>/src/$1',
},

// A preset that is used as a base for Jest's configuration
preset: 'ts-jest/presets/js-with-ts',

// The test environment that will be used for testing.
testEnvironment: 'jsdom',
testEnvironment: 'jest-environment-jsdom',

transform: {
'node_modules/.+\\.(j|t)sx?$': 'ts-jest',
},
// include projects from node_modules as required
transformIgnorePatterns: [
'node_modules/(?!yaml)',
],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
snapshotSerializers: [],

};
56 changes: 56 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@typescript-eslint/parser": "^5.53.0",
"babel-loader": "^8.3.0",
"babel-plugin-transform-imports": "^2.0.0",
"copy-webpack-plugin": "^6.2.1",
"css-loader": "^5.2.7",
"css-minimizer-webpack-plugin": "^4.2.2",
Expand Down Expand Up @@ -181,4 +182,4 @@
"monaco-editor": "^0.31.1"
}
}
}
}
2 changes: 1 addition & 1 deletion frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
"skipLibCheck": true
},
"include": ["**/*.ts", "**/*.tsx", "**/*.jsx", "**/*.js"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "public"]
}

0 comments on commit 810400c

Please sign in to comment.