From 26e65b079fe9da56ce3eac690fb427651801ce6b Mon Sep 17 00:00:00 2001
From: joao-fernandes
Date: Mon, 5 Aug 2019 14:33:49 +0200
Subject: [PATCH 1/2] docs: Document known issue with React 16.8
These warnings will be common among users with React 16.8. By adding
this to the README we can address a common concern until React 16.9
becomes common.
---
README.md | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/README.md b/README.md
index ac962d1b..e30e1730 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,7 @@ practices.
- [The problem](#the-problem)
- [This solution](#this-solution)
- [Installation](#installation)
+ - [Suppressing unnecessary warnings on React DOM 16.8](#suppressing-unnecessary-warnings-on-react-dom-168)
- [Examples](#examples)
- [Basic Example](#basic-example)
- [Complex Example](#complex-example)
@@ -108,6 +109,36 @@ use [the custom jest matchers](https://github.com/testing-library/jest-dom).
> [**Docs**](https://testing-library.com/react)
+### Suppressing unnecessary warnings on React DOM 16.8
+
+There is a known compatibility issue with React DOM 16.8 where you will see the
+following warning:
+
+```
+Warning: An update to ComponentName inside a test was not wrapped in act(...).
+```
+
+If you cannot upgrade to React DOM 16.9, you may suppress the warnings by adding
+the following snippet to your test configuration:
+
+```js
+// this is just a little hack to silence a warning that we'll get until react
+// fixes this: https://github.com/facebook/react/pull/14853
+const originalError = console.error
+beforeAll(() => {
+ console.error = (...args) => {
+ if (/Warning.*not wrapped in act/.test(args[0])) {
+ return
+ }
+ originalError.call(console, ...args)
+ }
+})
+
+afterAll(() => {
+ console.error = originalError
+})
+```
+
## Examples
### Basic Example
From a9cf184bc8ee56b9c150d5e359f62556f30a4955 Mon Sep 17 00:00:00 2001
From: "Kent C. Dodds"
Date: Mon, 5 Aug 2019 08:06:10 -0600
Subject: [PATCH 2/2] Update README.md
---
README.md | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index e30e1730..e8a1342f 100644
--- a/README.md
+++ b/README.md
@@ -119,11 +119,12 @@ Warning: An update to ComponentName inside a test was not wrapped in act(...).
```
If you cannot upgrade to React DOM 16.9, you may suppress the warnings by adding
-the following snippet to your test configuration:
+the following snippet to your test configuration
+([learn more](https://github.com/testing-library/react-testing-library/issues/281)):
```js
-// this is just a little hack to silence a warning that we'll get until react
-// fixes this: https://github.com/facebook/react/pull/14853
+// this is just a little hack to silence a warning that we'll get until we
+// upgrade to 16.9: https://github.com/facebook/react/pull/14853
const originalError = console.error
beforeAll(() => {
console.error = (...args) => {