Skip to content

Commit

Permalink
updated Jest developer guide
Browse files Browse the repository at this point in the history
  • Loading branch information
samithaf committed Aug 26, 2024
1 parent 2cfb20e commit c2a2dfc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,29 @@ export default function SampleApp() {

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.

Add the below to `package.json`
Update the `package.json` file if you have initialized your project with [Create React App](https://create-react-app.dev/).

```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/).

```js
{
transform: {
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/react/babel'] }]
},
transformIgnorePatterns: ['node_modules/(?!@westpac/ui)']
}
```

## Documentation

Visit [https://gel.westpacgroup.com.au/design-system](https://gel.westpacgroup.com.au/design-system) to view the full documentation.
Expand Down
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)']
}
`} />
```

0 comments on commit c2a2dfc

Please sign in to comment.