perry-mitchell / ulidx

ULID generator for NodeJS and the browser
MIT License
281 stars 17 forks source link

Testing with jest #39

Closed jongbelegen closed 7 months ago

jongbelegen commented 7 months ago

When I test with jest in my React native setup I get the following error:

Cannot find module 'ulidx

My jest setup looks like this:

  "jest": {
    "preset": "jest-expo",
    "setupFilesAfterEnv": [
      "@testing-library/jest-native/extend-expect",
      "<rootDir>/src/jestSetup"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!(?:.pnpm/)?((jest-)?react-native|@react-native(-community)?|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|@sentry/react-native|native-base|react-native-svg))"
    ],
    "moduleNameMapper": {
      "\\.(css)$": "<rootDir>/src/__mocks__/styleMock.ts"
    },
    "clearMocks": true
  },

Using jest-expo/node works, but it would be nice if the plugin would be testable with the standard React Native environment (iOS)

perry-mitchell commented 7 months ago

Hi. I'm not sure what the issue might be, but there's a large variety of things you need to consider when importing ESM-enabled libraries and I'm no jest expert.

As this isn't a bug or feature request I'll have to close it. It's most probably not related to this library but rather your project's configuration.