Skip to content

Commit

Permalink
refactor: transform react-native => ts & modify jestConfig: delete th… (
Browse files Browse the repository at this point in the history
  • Loading branch information
myNameIsDu committed Aug 2, 2021
1 parent 9e6523f commit 31b97f9
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 90 deletions.
14 changes: 5 additions & 9 deletions jest.config.js
@@ -1,18 +1,13 @@
const { defaults: tsjPreset } = require('ts-jest/presets')

const defaults = {
coverageDirectory: './coverage/',
collectCoverage: true,
testURL: 'http://localhost',
}
const testFolderPath = (folderName) => `<rootDir>/test/${folderName}/**/*.js`

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

const standardConfig = {
...defaults,
displayName: 'ReactDOM',
testMatch: NORMAL_TEST_FOLDERS.map(testFolderPath),
}

const tsTestFolderPath = (folderName) =>
`<rootDir>/test/${folderName}/**/*.{ts,tsx}`

Expand All @@ -26,13 +21,14 @@ const tsStandardConfig = {
const rnConfig = {
...defaults,
displayName: 'React Native',
testMatch: [testFolderPath('react-native')],
testMatch: [tsTestFolderPath('react-native')],
preset: 'react-native',
transform: {
'^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
...tsjPreset.transform,
},
}

module.exports = {
projects: [tsStandardConfig, standardConfig, rnConfig],
projects: [tsStandardConfig, rnConfig],
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -85,6 +85,7 @@
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9",
"@types/react-is": "^17.0.1",
"@types/react-native": "^0.64.12",
"@types/react-redux": "^7.1.18",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
Expand Down

0 comments on commit 31b97f9

Please sign in to comment.