expo-apple-authentication with Jest on bare project

Hello, I am using expo-apple-authentication in our RN bare project and it is working fine. I am trying to run tests on the code and we are using jest and react-native-testing-library. I am getting following error when I try to run the test.

Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/xxx/node_modules/@unimodules/core/build/index.js:1
    export * from './AdapterProxy';
    ^^^^^^

    SyntaxError: Unexpected token 'export'
        at compileFunction (<anonymous>)

      at Runtime._execModule (node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (node_modules/expo-apple-authentication/src/AppleAuthentication.ts:1:1)

I added expo-apple-authentication into transformIgnorePatterns but this issue is still showing. Do I need to use jest-expo to test this? I don’t have any expo features in my project except this Apple Authentication :smiley: … Thanks!

1 Like

When I added @unimodules in the transformIgnorePatterns, I get the following different error.

FAIL  src/__tests__/Navigation.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'viewManagersNames' of undefined

      at requireNativeViewManager (node_modules/@unimodules/react-native-adapter/src/NativeViewManagerAdapter.native.tsx:30:31)
      at Object.<anonymous> (node_modules/expo-apple-authentication/src/ExpoAppleAuthenticationButton.ts:15:46)
      at Object.<anonymous> (node_modules/expo-apple-authentication/src/AppleAuthenticationButton.tsx:8:1)

  console.warn
    The "UMNativeModulesProxy" native module is not exported through NativeModules; verify that @unimodules/react-native-adapter's native code is linked properly

      at Object.<anonymous> (node_modules/@unimodules/react-native-adapter/src/NativeModulesProxy.native.ts:41:11)
      at Object.<anonymous> (node_modules/@unimodules/react-native-adapter/src/index.ts:2:1)

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