Skip to content

Commit

Permalink
docs: add jest page
Browse files Browse the repository at this point in the history
  • Loading branch information
leegeunhyeok committed Oct 24, 2023
1 parent b14d080 commit 543ba1c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/docs/jest/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Testing with Jest",
"position": 6
}
44 changes: 44 additions & 0 deletions docs/docs/jest/custom-plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: Jest
sidebar_position: 3
slug: /jest
---

# Testing with Jest

`react-native-esbuild/jest` is a [Jest](https://jestjs.io) transformer.

It can replace [babel-jest](https://github.com/facebook/react-native/blob/v0.72.6/packages/react-native/jest-preset.js#L18) and supports the React Native testing environment.

## Setup

Open your `jest.config.js` and set `@react-native-esbuild/jest` as transformer.


Some internal of React Native or Libraries are not transformed.

```js
// Many react-native npm modules unfortunately don't pre-compile their source code before publishing.
// If you have npm dependencies that have to be transformed you can add the package name to list.
const TRANSFORM_PACKAGES = [
'react-native',
'jest-react-native',
'@react-native',
'@react-native-community',
'@react-navigation',
// ...
];

/**
* @type {import('jest').Config}
*/
module.exports = {
preset: 'react-native',
transform: {
'^.+\\.(t|j)sx?$': '@react-native-esbuild/jest',
},
transformIgnorePatterns: [
`node_modules/(?!${TRANSFORM_PACKAGES.join('|')})/`,
],
};
```
2 changes: 1 addition & 1 deletion docs/docs/limitations/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Limitations",
"position": 7
"position": 8
}
2 changes: 1 addition & 1 deletion docs/docs/troubleshooting/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Troubleshooting",
"position": 6
"position": 7
}

2 comments on commit 543ba1c

@vercel
Copy link

@vercel vercel bot commented on 543ba1c Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🔴 Statements 14.84% 359/2419
🔴 Branches 15.52% 137/883
🔴 Functions 10.27% 69/672
🔴 Lines 14.18% 316/2228

Test suite run success

83 tests passing in 10 suites.

Report generated by 🧪jest coverage report action from 543ba1c

Please sign in to comment.