Skip to content

Commit

Permalink
chore: setup test config for testing views
Browse files Browse the repository at this point in the history
For reasons the author of this commit doesn't understand, ts-jest won't
work with '@mturley-latest/react-table-batteries', which is used on all
views. But it worked just fine with babel-jest. So now we have this
frankenstein config, using both.
  • Loading branch information
bruno-fs committed Nov 14, 2024
1 parent 04965c7 commit afceab1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 11 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
module.exports = {};

module.exports = (api) => {
api.cache(true)
const presets = ["@babel/preset-react", "@babel/preset-env"];
const plugins = ["@babel/plugin-transform-modules-commonjs"];

return {
presets,
plugins
};
}
9 changes: 6 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ module.exports = {
testMatch: ['<rootDir>/**/__tests__/**/*.{ts,tsx}', '<rootDir>/**/*.{spec,test}.{ts,tsx}'],
testEnvironment: 'jsdom',
transform: {
'^.+\\.(js|jsx|ts|tsx)$': '<rootDir>/node_modules/ts-jest',
'^.+\\.(jsx|ts|tsx)$': '<rootDir>/node_modules/ts-jest',
// @mturley-latest/react-table-batteries lib proved to be challenging to properly transform
// using ts-jest; for this reason, js files are transformed with babel for now;
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'^.+\\.css$': '<rootDir>/config/jest.transform.style.js',
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '<rootDir>/config/jest.transform.file.js'
},
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$',
'[/\\\\]node_modules[/\\\\][/\\.+\\\\]*.+\\.(jsx|mjs|cjs|ts|tsx)$',
'^.+\\.module\\.(css|sass|scss)$'
],
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname']
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
};

0 comments on commit afceab1

Please sign in to comment.