Skip to content

Commit

Permalink
chore(enzyme): add patch to support react 16 context
Browse files Browse the repository at this point in the history
Enzyme does not support React 16.3 context API.
Patch the package until the package is realsed with the fix.
enzymejs/enzyme#1513
  • Loading branch information
rockstar-0000 committed Apr 26, 2018
1 parent a4f6289 commit 3c02acf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions patches/enzyme-adapter-react-16+1.1.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
patch-package
--- a/node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js
+++ b/node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js
@@ -56,6 +56,9 @@ var FunctionalComponent = 1;
var HostPortal = 4;
var HostComponent = 5;
var HostText = 6;
+var Mode = 11;
+var ContextConsumer = 12;
+var ContextProvider = 13;

function nodeAndSiblingsArray(nodeWithSibling) {
var array = [];
@@ -111,9 +114,6 @@ function toTree(vnode) {
instance: node.stateNode,
rendered: childrenToTree(node.child)
};
- case Fragment:
- // 10
- return childrenToTree(node.child);
case FunctionalComponent:
// 1
return {
@@ -145,6 +145,11 @@ function toTree(vnode) {
case HostText:
// 6
return node.memoizedProps;
+ case Fragment: // 10
+ case Mode: // 11
+ case ContextProvider: // 13
+ case ContextConsumer: // 12
+ return childrenToTree(node.child);
default:
throw new Error('Enzyme Internal Error: unknown node with tag ' + String(node.tag));
}

0 comments on commit 3c02acf

Please sign in to comment.