Skip to content

[Tests] use enzyme-adapter-react-helper; test on multiple react versions #118

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ljharb
Copy link
Collaborator

@ljharb ljharb commented Nov 17, 2017

This uses enzyme-adapter-react-helper to handle both configuring enzyme, as well as ensuring the proper react version is installed.

Based on react-dates/react-dates#846

@ljharb ljharb force-pushed the use_adapter_helper branch from 19967ed to 6896359 Compare November 17, 2017 22:35
@ljharb ljharb force-pushed the use_adapter_helper branch 2 times, most recently from f0e1acc to b54a658 Compare November 18, 2017 04:14
function MyComponent() {
return null;
class MyComponent extends React.Component {
render() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why convert to class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

SFCs don't work in React 0.13, and I was hoping to make the tests pass on it (only one fails rn)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Although actually I think I have a cleaner solution that will let us use SFCs inline, and reduce these diffs; i'll get that up in a few days.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Posted enzymejs/enzyme#1383; once merged and released, I'll use it here. The diff is much much smaller.

@ljharb ljharb force-pushed the use_adapter_helper branch from b54a658 to a780c3a Compare November 22, 2017 17:48
@ljharb ljharb force-pushed the use_adapter_helper branch 2 times, most recently from 3b432a2 to a29bc5b Compare November 27, 2017 07:52
@@ -59,7 +61,7 @@ describe('withStyles()', () => {
return null;
}

const WrappedComponent = withStyles(() => ({}))(MyComponent);
const WrappedComponent = withStyles(() => ({}))(safeSFC(MyComponent));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is an interesting solution, but I think it actually makes the tests less readable. My preference would be to not include this at all, and just not run tests against React 0.13.

@lencioni
Copy link
Collaborator

lencioni commented Jul 3, 2018

@ljharb Are you still interested in landing this change?

@ljharb
Copy link
Collaborator Author

ljharb commented Jul 3, 2018

Yep - I'm planning on adding a feature to enzyme (after the react work is done) that applies safeSFC inside the react 13 adapter, so that all this boilerplate can vanish.

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

Successfully merging this pull request may close these issues.

3 participants