Skip to content

Commit

Permalink
[frontend] configure jest to work with cuix
Browse files Browse the repository at this point in the history
We had to transform the cuix and cuix-core libraries in our jest testing setup in order to get the js modules working.
  • Loading branch information
bjornalm committed Oct 16, 2023
1 parent 490c154 commit beb3ba4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import '@testing-library/jest-dom';

import ReactExample from './ReactExample';

// For now, this is needed to mock cuix components exported as ESM (ECMAScript module)
jest.mock('cuix/dist/components/Button/PrimaryButton', () => () => undefined);
jest.mock('@cloudera/cuix-core/icons/react/PlusCircleIcon', () => () => undefined);

// Required by the antd Pagination component
window.matchMedia = jest.fn().mockImplementation(query => {
return {
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module.exports = {
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'vue'],
transformIgnorePatterns: ['node_modules/(?!(cuix|@cloudera/cuix-core)/)'],
transform: {
'^.+\\.(js|ts|jsx|tsx)$': 'babel-jest',
'^.+\\.vue$': '@vue/vue3-jest',
'^.+\\.vue$': '@vue/vue3-jest'
},
moduleNameMapper: {
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
Expand Down

0 comments on commit beb3ba4

Please sign in to comment.