File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ practices.</p>
56
56
- [ The problem] ( #the-problem )
57
57
- [ This solution] ( #this-solution )
58
58
- [ Installation] ( #installation )
59
+ - [ Suppressing unnecessary warnings on React DOM 16.8] ( #suppressing-unnecessary-warnings-on-react-dom-168 )
59
60
- [ Examples] ( #examples )
60
61
- [ Basic Example] ( #basic-example )
61
62
- [ Complex Example] ( #complex-example )
@@ -108,6 +109,36 @@ use [the custom jest matchers](https://github.com/testing-library/jest-dom).
108
109
109
110
> [ ** Docs** ] ( https://testing-library.com/react )
110
111
112
+ ### Suppressing unnecessary warnings on React DOM 16.8
113
+
114
+ There is a known compatibility issue with React DOM 16.8 where you will see the
115
+ following warning:
116
+
117
+ ```
118
+ Warning: An update to ComponentName inside a test was not wrapped in act(...).
119
+ ```
120
+
121
+ If you cannot upgrade to React DOM 16.9, you may suppress the warnings by adding
122
+ the following snippet to your test configuration:
123
+
124
+ ``` js
125
+ // this is just a little hack to silence a warning that we'll get until react
126
+ // fixes this: https://github.com/facebook/react/pull/14853
127
+ const originalError = console .error
128
+ beforeAll (() => {
129
+ console .error = (... args ) => {
130
+ if (/ Warning. * not wrapped in act/ .test (args[0 ])) {
131
+ return
132
+ }
133
+ originalError .call (console , ... args)
134
+ }
135
+ })
136
+
137
+ afterAll (() => {
138
+ console .error = originalError
139
+ })
140
+ ```
141
+
111
142
## Examples
112
143
113
144
### Basic Example
You can’t perform that action at this time.
0 commit comments