nandorojo / dripsy

šŸ· Responsive, unstyled UI primitives for React Native + Web.
https://dripsy.xyz
MIT License
1.98k stars 77 forks source link

how to run with jest #301

Closed jsellam closed 6 months ago

jsellam commented 6 months ago

Hi, I'm starting a new project with react-native (BARE) 0.72.6 I have added dripsy with typescript and all is working well on devices and simulator, but my tests with jest are not working.

I use @testing-library/jest-native/extend-expec and when I run "jest --no-cache" I have this error :

   /Users/jeremie/Documents/PROJETS/Metyis/kedrion/packages/front/mobile/node_modules/dripsy/build/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export * from './core';
Capture dā€™eĢcran 2023-12-18 aĢ€ 13 59 40

Do you know how to use dripsy with jest please ?

thx Jeremie.

nandorojo commented 6 months ago

Honestly not totally sure, I havenā€™t used jest much before besides simple functions.

jsellam commented 6 months ago

I have the answer, I have added this in jest.config.js

const libsThatRequiredCompilation = ['dripsy', '@expo/html-elements'].join('|');

module.exports = {
  preset: 'react-native',
  setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
  transformIgnorePatterns: [
    `node_modules/(?!((jest-)?react-native|${libsThatRequiredCompilation}|@react-native(-community)?)/)`,
  ],
};