sheremet-va / vitest-react-native

60 stars 4 forks source link

Compatibility with @testing-library/jest-native? #5

Closed wojtekmaj closed 9 months ago

wojtekmaj commented 1 year ago

Hi, first of all, thanks for maintaining this - amazing work. And quite brave tbh 😄

I'd like to know, if you've managed to make it compatible with @testing-library/jest-native somehow? As soon as I setup it, I get:

SyntaxError: Cannot use import statement outside a module
 ❯ Object.<anonymous> node_modules/@testing-library/jest-native/dist/to-be-visible.js:4:24

Module node_modules/react-native/index.js:14 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "react-native" asking them to ship the file in .mjs extension or add "type": "module" in their package.json.

As a temporary workaround you can try to inline the package by updating your config:

// vitest.config.js
export default {
  test: {
    deps: {
      inline: [
        "react-native"
      ]
    }
  }
}

The recommendation provided in the error does not work and I'm out of ideas…

wojtekmaj commented 9 months ago

Since the package is deprecated and matchers are now included in @testing-library/react-native, I'm closing this - no longer relevant.