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

ref(sentry-test/enzyme): Add migration warning message #29427

Merged
merged 3 commits into from
Oct 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions tests/js/sentry-test/enzyme.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import {cache} from '@emotion/css'; // eslint-disable-line emotion/no-vanilla
import {CacheProvider, ThemeProvider} from '@emotion/react';
import {mount, render, shallow} from 'enzyme'; // eslint-disable-line no-restricted-imports
import {mount, shallow as enzymeShallow} from 'enzyme'; // eslint-disable-line no-restricted-imports

import {lightTheme} from 'app/utils/theme';

/**
* @deprecated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was not sure if I should already add @deprecated here, since there will be an eslint rule too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having both is fine. The doc string annotation doesn't cost anything and could help folks who have TSC setup but not eslint in their editor.

* As we are migrating our tests to React Testing Library,
* please avoid using `sentry-test/enzyme/mountWithTheme` and use `sentry-test/reactTestingLibrary/mountWithTheme` instead.
*/
const mountWithTheme = (tree, opts) => {
const WrappingThemeProvider = props => (
<CacheProvider value={cache}>
Expand All @@ -14,4 +19,11 @@ const mountWithTheme = (tree, opts) => {
return mount(tree, {wrappingComponent: WrappingThemeProvider, ...opts});
};

export {mountWithTheme, render, shallow};
/**
* @deprecated
* As we are migrating our tests to React Testing Library,
* please avoid using `sentry-test/enzyme/shallow` and use `sentry-test/reactTestingLibrary/mountWithTheme` instead.
*/
const shallow = enzymeShallow;

export {mountWithTheme, shallow};