-
Notifications
You must be signed in to change notification settings - Fork 0
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
6 changed files
with
72 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
presets: [ | ||
'module:metro-react-native-babel-preset', | ||
'@babel/preset-env', | ||
'@babel/preset-react', | ||
'@babel/preset-typescript', | ||
], | ||
plugins: [ | ||
'react-native-reanimated/plugin', | ||
'@babel/plugin-transform-runtime', | ||
['@babel/plugin-proposal-private-methods', { loose: true }], | ||
['@babel/plugin-proposal-private-property-in-object', { loose: true }], | ||
['@babel/plugin-proposal-class-properties', { loose: true }], | ||
], | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// require('react-native-reanimated/lib/commonjs/reanimated2/jestUtils').setUpTests(); | ||
|
||
// eslint-disable-next-line global-require | ||
jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock')); |
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,4 +1,40 @@ | ||
const { defaults } = require('ts-jest/presets'); | ||
|
||
module.exports = { | ||
// ts的preset | ||
...defaults, | ||
// Jest 配置基础的预设 | ||
preset: 'react-native', | ||
|
||
// 模块使用的文件扩展名数组 | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
|
||
// 检测测试文件的模式(tests 目录下的 tsx 或 jsx 文件) | ||
testRegex: '(src/components/.*\\.(test|spec))\\.[tj]sx?$', | ||
|
||
// 匹配的路径下文件将跳过覆盖率信息 | ||
testPathIgnorePatterns: ['<rootDir>/node_modules/', '\\.snap$'], | ||
|
||
// 定义文件的编译方式 | ||
transform: { | ||
'^.+\\.tsx?$': [ | ||
'ts-jest', | ||
{ | ||
babelConfig: true, | ||
// tsconfig适配node modules下的一些文件 | ||
tsconfig: './tsconfig.test.json', | ||
}, | ||
], | ||
}, | ||
|
||
// 定义了忽略进行 jest 执行的依赖包 | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!(react-native|@react-native|@testing-library|react-navigation|@react-navigation/.*|@react-native-community|react-native-reanimated)/)', | ||
], | ||
|
||
// react-native-reanimated运行时需要一些配置 | ||
setupFilesAfterEnv: ['./jest-setup.js'], | ||
|
||
// 使用工作线程进行并行化 | ||
workerThreads: true, | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* @Author: yatessss | ||
* @Date: 2023-04-18 15:05:28 | ||
* @LastEditors: yatessss | ||
* @LastEditTime: 2023-04-18 15:05:37 | ||
* @Description: 用于jest的 tsconfig | ||
*/ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"isolatedModules": false | ||
} | ||
} |