imnapo / react-native-cn-quill

Quill rich-text editor for react-native
MIT License
190 stars 75 forks source link

Unable to run jest when using react-native-cn-quill #47

Closed hqtoan94 closed 3 years ago

hqtoan94 commented 3 years ago

About the error message:

 FAIL  src/__tests__/App.test.tsx
  ● Test suite failed to run

    Cannot find module '../assets/icons/align-left.png' from 'node_modules/react-native-cn-quill/lib/src/constants/icons.js'

    Require stack:
      node_modules/react-native-cn-quill/lib/src/constants/icons.js
      node_modules/react-native-cn-quill/lib/src/utils/toolbar-utils.js
      node_modules/react-native-cn-quill/lib/src/toolbar/quill-toolbar.js
      node_modules/react-native-cn-quill/lib/src/index.js
      src/scenes/EditCard/EditCard.tsx
      src/scenes/EditCard/index.ts
      src/App.tsx
      src/__tests__/App.test.tsx

at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
      at Object.<anonymous> (node_modules/react-native-cn-quill/lib/src/constants/icons.js:1:23)

  console.error
    react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).

    For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation

      at Object.<anonymous> (node_modules/react-native-gesture-handler/lib/commonjs/RNGestureHandlerModule.ts:5:3)
      at Object.<anonymous> (node_modules/react-native-gesture-handler/lib/commonjs/handlers/createHandler.ts:10:1)

I have added transformIgnorePatterns like this in jest.config.js but it doesn't work:

module.exports = {
  preset: 'react-native',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
  transformIgnorePatterns: [
    'node_modules/(?!@react-native|react-native|@react-navigation)',
  ],
};
imnapo commented 3 years ago

@hqtoan94 , I removed image files and replaced them with base64 strings in the new update to fix this issue. Let me now if it works.

imnapo commented 3 years ago

I'm closing this issue now, Feel free to reopen if the problem still exists.