-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[New] add enzyme-adapter-react-17
#2430
base: master
Are you sure you want to change the base?
Conversation
} | ||
} | ||
ReactDOM.render(React.createElement(Tester), container); | ||
return inst._reactInternals.child; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change there, facebook/react#18377
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2430 +/- ##
==========================================
- Coverage 96.12% 95.61% -0.52%
==========================================
Files 49 53 +4
Lines 4004 4516 +512
Branches 1123 1288 +165
==========================================
+ Hits 3849 4318 +469
- Misses 155 198 +43 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a reason that issue did not have the "help wanted" label on it; thanks for the contribution, but I already have the majority of this change coded and am in the process of testing it.
Please leave this PR open so i can update it, otherwise the PR ref will be left orphaned.
Dear @layershifter thanks for the PR! Any update on this? |
FYI, this might be affected by the bug reported in my temporary adapter repo: |
I stopped to work on it after @ljharb comment: #2430 (review). I am also interested in getting this. |
Indeed, that linked bug is one of the blockers I've run into in my local work. I'd be more than happy to pull in additional commits to this PR, and to my local implementation, in service of getting something published ASAP. |
2ceb4b3
to
9d78683
Compare
I've rebased this branch and included my WIP. There's still 8 failing tests (and 2 I've temporarily patched), that fall into these categories:
Please post links to commits/branches, and I'll pull them into the PR. |
9d78683
to
02fb6a5
Compare
|
@eps1lon awesome, thanks! the other side of this is, how do i locate, off of the FiberNode, what should be rendered? It's got a bunch of circular references. The best I could come up with makes this: class Component extends React.Component {
render() {
return (
<div>test</div>
);
}
}
const SuspenseComponent = () => (
<Suspense fallback={Fallback}>
<Component />
</Suspense>
); map to this: <SuspenseComponent>
<Suspense fallback={[Function: Fallback]}>
<Suspense mode="visible" />
</Suspense>
</SuspenseComponent> with this: case FiberTags.OffscreenComponent: {
console.log(node.return.memoizedProps.children);
return {
nodeType: 'function',
type: Suspense,
props: { ...node.memoizedProps },
key: ensureKeyOrUndefined(node.key),
ref: node.ref,
instance: null,
rendered: childrenToTree(nodeToHostNode(node.return.memoizedProps.children)),
};
} |
I don't have more context on how the OffscreenComponent is handled internally in React. From what I could gather it's used in different scenarios. Some only available with experimental APIs. If you can add a test I might be able to help. |
@eps1lon thanks! the test is already there; i've updated the branch to have my best output so far. |
02fb6a5
to
c45bf1a
Compare
@ljharb diff --git a/packages/enzyme-adapter-react-17/src/ReactSeventeenAdapter.js b/packages/enzyme-adapter-react-17/src/ReactSeventeenAdapter.js
index 0e69131..bb3477d 100644
--- a/packages/enzyme-adapter-react-17/src/ReactSeventeenAdapter.js
+++ b/packages/enzyme-adapter-react-17/src/ReactSeventeenAdapter.js
@@ -299,16 +299,7 @@ function toTree(vnode) {
case FiberTags.Lazy:
return childrenToTree(node.child);
case FiberTags.OffscreenComponent: {
- console.log(node.return.memoizedProps.children);
- return {
- nodeType: 'function',
- type: Suspense,
- props: { ...node.memoizedProps },
- key: ensureKeyOrUndefined(node.key),
- ref: node.ref,
- instance: null,
- rendered: childrenToTree(nodeToHostNode(node.return.memoizedProps.children)),
- };
+ return toTree(node.child);
}
default:
throw new Error(`Enzyme Internal Error: unknown node with tag ${node.tag}`);
diff --git a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
index c77bf15..234da0b 100644
--- a/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
+++ b/packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
@@ -1112,7 +1112,7 @@ describeWithDOM('mount', () => {
}
}
- it.only('finds Suspense and its children when no lazy component', () => {
+ it('finds Suspense and its children when no lazy component', () => {
class Component extends React.Component {
render() {
return (
@@ -1130,7 +1130,6 @@ describeWithDOM('mount', () => {
const wrapper = mount(<SuspenseComponent />);
expect(wrapper.is(SuspenseComponent)).to.equal(true);
- console.log(wrapper.debug());
expect(wrapper.find(Component)).to.have.lengthOf(1);
expect(wrapper.find(Fallback)).to.have.lengthOf(0);
});
the suspense tests are passing. |
This comment has been minimized.
This comment has been minimized.
Hi all, firstly thanks for all your hard work on this project. Has this PR stalled? I'm not quite sure what state it's in apart from it's failing code coverage right now. I'm probably one of many people who rely on packages that use this under the hood and are not able to upgrade to React 17 (safely) until this gets updated. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as off-topic.
This comment was marked as off-topic.
What are the options for developers and projects with thousands of Enzyme for React 16 tests? Is this worth any more waiting or better to migrate off Enzyme? |
@igorpupkinable unfortunately there isn't any alternative to enzyme for the majority of what enzyme provides. I still intend to complete this task; I'm hoping next month. |
This comment was marked as spam.
This comment was marked as spam.
@chyzwar @igorpupkinable RTL and Enzyme are VERY different, and people who migrate to RTL expecting to get feature parity with Enzyme are going to be sorely disappointed. |
This decision by the react team and airbnb team remind me a bit of the angular 2 -> 3 decision making process. It makes sense from a |
@createthis which decision are you referring to? React decided they no longer wanted to have to consider enzyme users when changing React internals. Airbnb decided they didn't want to maintain the package, and I've been doing so, unfunded, on my own, for many years. Nobody has decided enzyme shouldn't or won't support React 17+, it's just that out of all the people who've complained about their company's codebases, ZERO of them have provided funding or programmer time to make it happen. |
Yes. |
To be clear though, while I certainly am not happy about those two companies' decisions here, the blame (if there must be "blame") is shared equally by every single user of the project (individuals and/or corporations) who isn't contributing time and/or money to supporting it. Open Source is not an inexhaustible source of free labor, as much as I wish the world's legal and economic systems were set up for that to be feasible. |
Agreed. It's all just js in the end. Anyone can contribute. I did my best to move the ball forward. I got stuck and blocked on the rebase issues. If anyone could unblock me I might be willing to try again. That said, without major company support from fb or airbnb or another large company using the ecosystem, it may be an uphill battle not worth fighting. Sometimes it's better to just go with the flow. |
While I sympathize with this statement, I would suggest that a maintainer should still ensure that critical issues are resolved in a timely fashion (such as people not being able to update React because this dep is holding them back). If this cannot be done in say 2 years, then it's normal for users to be considering alternatives. I know what being a lone maintainer feels like (maybe not at this scale though!), but I think it wouldn't be helpful for me to blame users for my inability to maintain the project that I own. I'm the maintainer, after all. If there was a situation where I couldn't maintain my projects, I would put a disclaimer or archive the project for the reasons mentioned (lack of time, lack of funding, lack of help, etc). Until a firm commitment to fix/prioritization is made by the maintainer there will inevitably be a cloud of doubt and people will be asking for status and talking about alternatives, it's just normal. Another thing I want to add: It's not because a project is OSS that people will help maintain the project. People use OSS mostly to ensure deps are peer-reviewed and do not contain malware. People will still ping the maintainer, because only the maintainer is expected to maintain the project. Hopefully the React team/@gaearon and Enzyme can reach some solution (maybe a compatibility layer) as this project is undeniably useful to many. |
43eb75e
to
39e6b1f
Compare
Fixes #2429.