From beb3ba4ed51316c0f05afb3efe592e403dcd7791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Alm?= Date: Mon, 16 Oct 2023 14:52:30 -0700 Subject: [PATCH] [frontend] configure jest to work with cuix We had to transform the cuix and cuix-core libraries in our jest testing setup in order to get the js modules working. --- .../components/result/reactExample/ReactExample.test.tsx | 4 ---- jest.config.js | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/desktop/core/src/desktop/js/apps/editor/components/result/reactExample/ReactExample.test.tsx b/desktop/core/src/desktop/js/apps/editor/components/result/reactExample/ReactExample.test.tsx index e965e700a8d..7468132d088 100644 --- a/desktop/core/src/desktop/js/apps/editor/components/result/reactExample/ReactExample.test.tsx +++ b/desktop/core/src/desktop/js/apps/editor/components/result/reactExample/ReactExample.test.tsx @@ -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 { diff --git a/jest.config.js b/jest.config.js index 2ce952d5486..42f35d2a607 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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',