Parcourir la source

[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.
Björn Alm il y a 2 ans
Parent
commit
deac365627

+ 0 - 4
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 {

+ 2 - 1
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',