Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running jest tests rendering components created with createText() cause tests to fail with an exception #165

Open
tonyseing opened this issue Jun 28, 2022 · 8 comments

Comments

@tonyseing
Copy link

tonyseing commented Jun 28, 2022

I'm writing a jest test case that renders a Text component created from the following line of code: export const Text = createText<IotTheme>();

I receive a resulting error:

  TypeError: funcsMap[propKey] is not a function

      at node_modules/@shopify/restyle/dist/composeRestyleFunctions.js:33:137
          at Array.reduce (<anonymous>)
      at Object.buildStyle (node_modules/@shopify/restyle/dist/composeRestyleFunctions.js:33:41)
      at Object.func [as variant] (node_modules/@shopify/restyle/dist/createVariant.js:36:70)
      at node_modules/@shopify/restyle/dist/composeRestyleFunctions.js:33:137
          at Array.reduce (<anonymous>)
      at Object.buildStyle (node_modules/@shopify/restyle/dist/composeRestyleFunctions.js:33:41)
      at node_modules/@shopify/restyle/dist/hooks/useRestyle.js:48:45
      at mountMemo (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6877:19)
      at Object.useMemo (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:7213:16)
@timgremore
Copy link

@tonyseing I just bumped into this same error. Did you happen to find a solution?

@tonyseing
Copy link
Author

@timgremore I added a mock in my jest tests. Found this solution in another issue ticket here but it suited my case perfectly for the timebeing:

jest.mock('@shopify/restyle', () => { const RealModule = jest.requireActual('@shopify/restyle'); const RN = jest.requireActual('react-native'); RealModule.createText = () => RN.Text; RealModule.createBox = () => RN.View; RealModule.createRestyleComponent = (f, c) => c || RN.View; return RealModule;

@timgremore
Copy link

@tonyseing This ended up being an invalid style prop (background where backgroundColor was expected) for me.

@tonyseing
Copy link
Author

@timgremore thanks for the tip! I'll give this another look-see

@anthlasserre
Copy link

anthlasserre commented Jan 16, 2023

On my side I figure it out by removing transform style property in some of my variants in textVariant.

@fortmarek
Copy link
Contributor

Is this still an issue? If so, could you provide full reproduction steps?

@ellited
Copy link

ellited commented Feb 10, 2023

For me helped answer from this closed ticket: #102 (comment)

@9lan
Copy link

9lan commented Sep 5, 2024

For me, I was moving the RestyleThemeProvider on top of another ThemeProvider.

Example:

import {ThemeProvider as RestyleThemeProvider} from '@shopify/restyle';
import {ThemeProvider as AnotherThemeProvider} from 'another-theme-provider';

<RestyleThemeProvider>
   <AnotherThemeProvider>
     // code here
  </AnotherThemeProvider>
</RestyleThemeProvider>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants