Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Useffect in react-testing-library custom render function

I need to create a custom renderer function for react-testing-library to test all my components.

I need to fetch my app's redux store from createStoreManager which returns promise. I am using useEffect to call this function but useEffect is not getting called.

or is there any way to get a response from this fn createStoreManager?

import React, { useEffect, useState } from 'react';
import { render as rtlRender } from '@testing-library/react';
import { IntlProvider } from 'react-intl';
import { StoreProvider } from './provider';
import { createStoreManager } from './store';

const getOurStore = async () => {
   const storeManager = await createStoreManager({
    pageName: '',
    sagaContext: {},
    initialState: {},
    sagaMonitor: null,
  });
  const { store } = storeManager;
  return store;
};

const Wrapper = ({ children }) => {
  let store;

  **// Not getting called**
  useEffect(() => {
    (async () => {
      store = await getOurStore();
    })();
  });

  return (
    <IntlProvider locale="en" messages="test"> 
      <StoreProvider store={store}>{children}</StoreProvider>
    </IntlProvider>
  );
};

function render(ui, options) {
  return rtlRender(ui, { wrapper: Wrapper, ...options });
}

// re-export everything
export * from '@testing-library/react';
// override render method
export { render };

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!