From bf2a1f00485fec55a7065ce6a8d79b152dafe99f Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Wed, 22 Jun 2022 14:38:06 +0530 Subject: [PATCH 1/3] Add myself to contributers list --- .all-contributorsrc | 9 +++++++++ README.md | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index b8a61f52..6a0da16e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -603,6 +603,15 @@ "contributions": [ "doc" ] + }, + { + "login": "amovar18", + "name": "Kudaligi Amoghavarsha", + "avatar_url": "https://avatars.githubusercontent.com/u/59614577?v=4", + "profile": "https://github.com/amovar18", + "contributions": [ + "maintenance" + ] } ], "skipCi": true, diff --git a/README.md b/README.md index c9fca586..0361e711 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ library will instead be included as official additions to both `react-testing-li ([PR](https://github.com/callstack/react-native-testing-library/pull/923)) with the intention being to provide a more cohesive and consistent implementation for our users. -Please be patient as we finalise these changes in the respective testing libraries. -In the mean time you can install `@testing-library/react@^13.1` +Please be patient as we finalise these changes in the respective testing libraries. In the mean time +you can install `@testing-library/react@^13.1` ## Table of Contents @@ -263,6 +263,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Masious

📖
Laishuxin

📖 + +
Kudaligi Amoghavarsha

🚧 + From 1f5b5642b28c7c8ea9a46bdca5c92feb555b1b2f Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Wed, 22 Jun 2022 14:39:04 +0530 Subject: [PATCH 2/3] Add error handling to hydrate function --- src/server/pure.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/server/pure.ts b/src/server/pure.ts index aa62a283..58a645c1 100644 --- a/src/server/pure.ts +++ b/src/server/pure.ts @@ -29,11 +29,13 @@ function createServerRenderer( if (container) { throw new Error('The component can only be hydrated once') } else { - container = document.createElement('div') - container.innerHTML = serverOutput - act(() => { - ReactDOM.hydrate(testHarness(renderProps), container!) - }) + if (typeof document !== 'undefined') { + container = document.createElement('div') + container.innerHTML = serverOutput + act(() => { + ReactDOM.hydrate(testHarness(renderProps), container!) + }) + } } }, rerender(props?: TProps) { From ce72ef4a6f5692122a5010c241e31b9a6e226551 Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Wed, 22 Jun 2022 14:41:34 +0530 Subject: [PATCH 3/3] Add a error message for hydrate --- src/server/pure.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/server/pure.ts b/src/server/pure.ts index 58a645c1..a00034e6 100644 --- a/src/server/pure.ts +++ b/src/server/pure.ts @@ -35,6 +35,10 @@ function createServerRenderer( act(() => { ReactDOM.hydrate(testHarness(renderProps), container!) }) + } else { + throw new Error( + 'Hydrate function can only be called in a client environment with a document available.' + ) } } },