Can not use jest-expo/universal with @testing-library/react

Please provide the following:

  1. SDK Version: 37.0.8
  2. Platforms(Android/iOS/web/all): Web

I’m trying to use jest-expo/universal preset with @testing-library/react & react-native-testing-library to test the functionality. For now I separated the test file for native & web, it works in native, but in web I got this error:

/path-to-project/node_modules/dom-accessibility-api/dist/accessible-name.mjs:4
import ArrayFrom from “./polyfills/array.from.mjs”;
^^^^^^

SyntaxError: Cannot use import statement outside a module

I’ve tried this solution (https://github.com/testing-library/react-testing-library/issues/646), but it only works when we use jest-expo/web. Anyone ever encountered this problem?

Also experiencing this problem. Cant run any tests with Jest and Expo even with regular jest-expo preset. Fresh project, following the documentation also yields the same result. Can’t test.

The specific mjs issue appears to be covered by this issue: https://github.com/expo/expo/issues/8809

But it’d be good to see some more general guidance on what is and isn’t supported and possible using @testing-library etc with jest-expo/universal

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.