facebookexperimental / Recoil

Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.
https://recoiljs.org/
MIT License
19.59k stars 1.18k forks source link

Recoil-Sync syncEffect Jest error #2307

Open SocDario opened 7 months ago

SocDario commented 7 months ago

Hello,

I am facing an issue with testing recoil-sync with Jest. It's about default test generated along with React Native.

Versions:

"recoil": "0.7.7", "recoil-sync": "0.2.0", "jest": "29.2.1", "@recoiljs/refine": "0.1.1"

Below is a test file of creating App component:

/**
 * @format
 */
// Note: import explicitly to use the types shiped with jest.
import { it } from '@jest/globals';
import 'react-native';
import React from 'react';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

import App from '../App';

it('renders correctly', () => {
  renderer.create(<App />);
});

Getting the following error on running test:

FAIL  __tests__/App.test.tsx
  ● Test suite failed to run

    TypeError: (0 , _recoilSync.syncEffect) is not a function

      10 |   default: undefined,
      11 |   effects: [
    > 12 |     syncEffect({
         |               ^
      13 |       storeKey: Storage.AsyncStorage,
      14 |       refine: nullable(
      15 |         object({

      at Object.<anonymous> (src/modules/authentication/state/atoms.ts:12:15)
      at Object.require (src/modules/authentication/state/index.ts:1:1)
      at Object.require (src/modules/authentication/index.ts:1:1)
      at Object.require (src/modules/apollo-client/hooks/useApolloClientSetup.ts:15:1)
      at Object.require (src/modules/apollo-client/hooks/index.ts:1:1)
      at Object.require (src/modules/apollo-client/components/ApolloClientProvider.tsx:4:1)
      at Object.require (src/modules/apollo-client/components/index.ts:1:1)
      at Object.require (src/modules/apollo-client/index.ts:1:1)
      at Object.require (App.tsx:8:1)
      at Object.require (__tests__/App.test.tsx:12:1)