File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ id: example-react-intl
3
3
title : React Intl
4
4
---
5
5
6
+ > ** Note**
7
+ >
8
+ > If you want to combine setupTests with another setup you should check
9
+ > [ ` setup ` ] ( react-testing-library/setup.md )
10
+
6
11
``` jsx
7
12
import React from ' react'
8
13
import ' jest-dom/extend-expect'
@@ -36,9 +41,7 @@ const FormatDateView = () => {
36
41
}
37
42
38
43
const renderWithReactIntl = component => {
39
- return {
40
- ... render (< IntlProvider locale= " pt" > {component}< / IntlProvider> ),
41
- }
44
+ return render (< IntlProvider locale= " pt" > {component}< / IntlProvider> )
42
45
}
43
46
44
47
setupTests ()
Original file line number Diff line number Diff line change @@ -226,3 +226,29 @@ mocha --require jsdom-global/register
226
226
Note, depending on the version of Node you're running, you may also need to
227
227
install @babel/polyfill (if you're using babel 7) or babel-polyfill (for babel
228
228
6).
229
+
230
+ ## Configuring React-Intl Polyfills
231
+
232
+ If you're using React-Intl in your project, and you need to load a locale, you
233
+ must load the Polyfills according to that language.
234
+
235
+ In order to do so, you may use this small setup and/or combine it with other
236
+ setups.
237
+
238
+ ```
239
+ // src/setupTests.js
240
+ import IntlPolyfill from 'intl'
241
+ import 'intl/locale-data/jsonp/pt'
242
+
243
+ const setupTests = () => {
244
+ // https://formatjs.io/guides/runtime-environments/#server
245
+ if (global.Intl) {
246
+ Intl.NumberFormat = IntlPolyfill.NumberFormat
247
+ Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat
248
+ } else {
249
+ global.Intl = IntlPolyfill
250
+ }
251
+ }
252
+
253
+ setupTests();
254
+ ```
You can’t perform that action at this time.
0 commit comments