-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 18 additions & 2 deletions
20
...rc/content/design-system/development/guides/unit-testing/design/unit-testing/content.mdoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
We recommend [Vitest](https://vitest.dev/) for unit testing since [Vitest](https://vitest.dev/guide/why.html) natively supports [ES modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). | ||
|
||
If you are using [Jest](https://jestjs.io/) for unit testing, you might encounter some issues since [Jest](https://jestjs.io/docs/ecmascript-modules) does not support [ES modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) by default. Therefore, you will need to make following configuration changes to the [Jest configuration file](https://jestjs.io/docs/configuration). | ||
If you are using [Jest](https://jestjs.io/) for unit testing, you might encounter some issues since [Jest](https://jestjs.io/docs/ecmascript-modules) does not support [ES modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) by default. Therefore, you will need to make following configuration changes. | ||
|
||
Update the `package.json` file if you have initialized your project with [Create React App](https://create-react-app.dev/). | ||
|
||
```html | ||
<StaticCode language="jsx" code={` | ||
// package.json | ||
{ | ||
"scripts": { | ||
"test": "jest --transformIgnorePatterns \"node_modules/(?!(@westpac/ui)/)\"" | ||
"test": "node scripts/test.js --transformIgnorePatterns \"node_modules/(?!(@westpac/ui)/)\"" | ||
} | ||
} | ||
`} /> | ||
``` | ||
|
||
Update the `jest.config.js` file if you have initialized your project with [Nx build system](https://nx.dev/) and [Babel](https://babeljs.io/). | ||
|
||
```html | ||
<StaticCode language="jsx" code={` | ||
// jest.config.js | ||
{ | ||
transform: { | ||
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/react/babel'] }] | ||
}, | ||
transformIgnorePatterns: ['node_modules/(?!@westpac/ui)'] | ||
} | ||
`} /> | ||
``` |