Skip to content

Commit b342fae

Browse files
Add guidance on testing to the Getting Started docs (#2916)
* Add guidance on testing to the getting started docs * add import paths for test-helpers
1 parent d581110 commit b342fae

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/content/getting-started.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,12 @@ Of course, customize the array based on the `@types/` packages you have installe
134134
## Silencing warnings
135135

136136
Like React, Primer React emits warnings to the JavaScript console under certain conditions, like using deprecated components or props. Similar to React, you can silence these warnings by setting the `NODE_ENV` environment variable to `production` during bundling.
137+
138+
## Testing
139+
140+
Testing your application with Primer React is no different than testing your application with any other React library. Depending on your test environment and the testing libraries you use, you may need polyfills. For example if you are using `jest`, it runs via Node runtime and uses [JSDOM](https://github.com/jsdom/jsdom) as a DOM implementation, so you will need to mock some browser APIs. We have [helpers](https://github.com/primer/react/blob/main/src/utils/test-helpers.tsx) that you can utilize to mock some of these APIs. You can import the helpers in your test setup file like so:
141+
142+
```js
143+
import '@primer/react/lib-esm/utils/test-helpers' // For ESM
144+
import '@primer/react/lib/utils/test-helpers' // For CommonJS
145+
```

0 commit comments

Comments
 (0)