enzyme.js 664 B

12345678910111213141516171819
  1. import {mount, shallow, render} from 'enzyme'; // eslint-disable-line no-restricted-imports
  2. import {CacheProvider} from '@emotion/core';
  3. import {ThemeProvider} from 'emotion-theming';
  4. import {cache} from 'emotion'; // eslint-disable-line emotion/no-vanilla
  5. import React from 'react';
  6. import theme from 'app/utils/theme';
  7. const mountWithTheme = (tree, opts) => {
  8. const WrappingThemeProvider = props => (
  9. <CacheProvider value={cache}>
  10. <ThemeProvider theme={theme}>{props.children}</ThemeProvider>
  11. </CacheProvider>
  12. );
  13. return mount(tree, {wrappingComponent: WrappingThemeProvider, ...opts});
  14. };
  15. export {mountWithTheme, mount, shallow, render};