Skip to content

Commit 31b97f9

Browse files
authored
refactor: transform react-native => ts & modify jestConfig: delete th… (#1786)
1 parent 9e6523f commit 31b97f9

File tree

5 files changed

+189
-90
lines changed

5 files changed

+189
-90
lines changed

jest.config.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1+
const { defaults: tsjPreset } = require('ts-jest/presets')
2+
13
const defaults = {
24
coverageDirectory: './coverage/',
35
collectCoverage: true,
46
testURL: 'http://localhost',
57
}
6-
const testFolderPath = (folderName) => `<rootDir>/test/${folderName}/**/*.js`
78

89
const NORMAL_TEST_FOLDERS = ['components', 'hooks', 'integration', 'utils']
910

10-
const standardConfig = {
11-
...defaults,
12-
displayName: 'ReactDOM',
13-
testMatch: NORMAL_TEST_FOLDERS.map(testFolderPath),
14-
}
15-
1611
const tsTestFolderPath = (folderName) =>
1712
`<rootDir>/test/${folderName}/**/*.{ts,tsx}`
1813

@@ -26,13 +21,14 @@ const tsStandardConfig = {
2621
const rnConfig = {
2722
...defaults,
2823
displayName: 'React Native',
29-
testMatch: [testFolderPath('react-native')],
24+
testMatch: [tsTestFolderPath('react-native')],
3025
preset: 'react-native',
3126
transform: {
3227
'^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
28+
...tsjPreset.transform,
3329
},
3430
}
3531

3632
module.exports = {
37-
projects: [tsStandardConfig, standardConfig, rnConfig],
33+
projects: [tsStandardConfig, rnConfig],
3834
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"@types/react": "^17.0.14",
8686
"@types/react-dom": "^17.0.9",
8787
"@types/react-is": "^17.0.1",
88+
"@types/react-native": "^0.64.12",
8889
"@types/react-redux": "^7.1.18",
8990
"@typescript-eslint/eslint-plugin": "^4.28.0",
9091
"@typescript-eslint/parser": "^4.28.0",

0 commit comments

Comments
 (0)