Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Created March 31, 2020 15:25
Show Gist options
  • Save nathansmith/b486e7d841df3abd0d9801a0978a2b8f to your computer and use it in GitHub Desktop.
Save nathansmith/b486e7d841df3abd0d9801a0978a2b8f to your computer and use it in GitHub Desktop.
Forces `useEffect` to be called in Jest tests
import React from 'react';
import { render } from 'react-dom';
// Helper.
const callUseEffect = () => {
const Noop = () => null;
const root = document.createElement('div');
render(<Noop />, root);
};
// Export.
export { callUseEffect };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment