From 8c825f7d14a5661f3223a31b18719e25bbb34a29 Mon Sep 17 00:00:00 2001 From: Webster-Butterfly Date: Thu, 26 Apr 2018 12:33:46 +0100 Subject: [PATCH] chore(enzyme): add patch to support react 16 context Enzyme does not support React 16.3 context API. Patch the package until the package is realsed with the fix. https://github.com/airbnb/enzyme/pull/1513 --- patches/enzyme-adapter-react-16+1.1.1.patch | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 patches/enzyme-adapter-react-16+1.1.1.patch diff --git a/patches/enzyme-adapter-react-16+1.1.1.patch b/patches/enzyme-adapter-react-16+1.1.1.patch new file mode 100644 index 0000000..811490f --- /dev/null +++ b/patches/enzyme-adapter-react-16+1.1.1.patch @@ -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)); + }