Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: modify jest config, ts-jest => 26.xx.xx, tsconfig'include add … #1770

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions jest.config.js
@@ -1,14 +1,9 @@
const { default: tsJestPreset } = require('ts-jest')

const defaults = {
...tsJestPreset,
coverageDirectory: './coverage/',
collectCoverage: true,
testURL: 'http://localhost',
}

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

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

Expand All @@ -18,6 +13,16 @@ const standardConfig = {
testMatch: NORMAL_TEST_FOLDERS.map(testFolderPath),
}

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

const tsStandardConfig = {
...defaults,
displayName: 'ReactDOM',
preset: 'ts-jest',
testMatch: NORMAL_TEST_FOLDERS.map(tsTestFolderPath),
}

const rnConfig = {
...defaults,
displayName: 'React Native',
Expand All @@ -29,5 +34,5 @@ const rnConfig = {
}

module.exports = {
projects: [standardConfig, rnConfig],
projects: [tsStandardConfig, standardConfig, rnConfig],
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -109,7 +109,7 @@
"rimraf": "^3.0.2",
"rollup": "^2.32.1",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^27.0.3",
"ts-jest": "26.5.6",
Copy link
Member

Choose a reason for hiding this comment

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

Why is this being downgraded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I was using ts-jest@27, I encountered some problems
Then I upgraded jest to version 27 and encountered this problem again
In the end, I can only use version 26 first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In addition,I will fix the problem left over from converting the TS file, But this may take some time, as strict type checking may require a lot of additional fixes:cold_sweat:

"typescript": "^4.3.4"
},
"browserify": {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Expand Up @@ -272,6 +272,6 @@ export type ResolveArrayThunks<TDispatchProps extends ReadonlyArray<any>> =
export interface TypedUseSelectorHook<TState> {
<TSelected>(
selector: (state: TState) => TSelected,
equalityFn?: (left: TSelected, right: TSelected) => boolean
equalityFn?: EqualityFn<TSelected>
): TSelected
}
4 changes: 2 additions & 2 deletions tsconfig.json
Expand Up @@ -11,8 +11,8 @@
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./es",
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
},
"include": ["src/**/*", "types"],
"include": ["src/**/*", "test/**/*", "types"],
"exclude": ["node_modules", "dist"]
}
55 changes: 15 additions & 40 deletions yarn.lock
Expand Up @@ -3571,9 +3571,9 @@ __metadata:
linkType: hard

"@types/normalize-package-data@npm:^2.4.0":
version: 2.4.0
resolution: "@types/normalize-package-data@npm:2.4.0"
checksum: 6d077e73be7ac6227b678829c7bd765607136cdef537fd4ee7f368d9302a651aea924254d69826663322048436d90d6e7c679c9aa99c4824a687c568aab8ce4f
version: 2.4.1
resolution: "@types/normalize-package-data@npm:2.4.1"
checksum: d7bb5756003a5dbf3ea1ee24ee336c036f3670a7f1ca2c8c840b5ba8fdf4b7063f8d8df16ec0427f622cc97e1c44710f089720d7caa521a5f4ec6f4073c69261
languageName: node
linkType: hard

Expand All @@ -3599,9 +3599,9 @@ __metadata:
linkType: hard

"@types/prettier@npm:^2.0.0":
version: 2.3.1
resolution: "@types/prettier@npm:2.3.1"
checksum: 62ddbb1ba05d0df97fe49536e0d5409ea76d45cd2f6de062ff351d049e667b77010d2e912733d5d3255829fa1958c684a059e619f9d81e2ba9f27a6204a06149
version: 2.3.2
resolution: "@types/prettier@npm:2.3.2"
checksum: 7b425386aaf3b03fa63382ed1aceff367477ef9a52a2705978bfb1495fa1d8795316e1ab84671f6c8c5920de59a33d1567d837b9eb033996983efdfdbce84cb3
languageName: node
linkType: hard

Expand Down Expand Up @@ -5606,7 +5606,7 @@ __metadata:
languageName: node
linkType: hard

"ci-info@npm:^3.0.0, ci-info@npm:^3.1.1":
"ci-info@npm:^3.0.0":
version: 3.2.0
resolution: "ci-info@npm:3.2.0"
checksum: d4a898d60111d00f2b7a06a349162971fe0603aefa208fe8d1343ce9e93c48e3d37311c47211d5c9040d25b43038c817588e5b7d8eab5d17b00aec49c7b5fade
Expand Down Expand Up @@ -9694,17 +9694,6 @@ __metadata:
languageName: node
linkType: hard

"is-ci@npm:^3.0.0":
version: 3.0.0
resolution: "is-ci@npm:3.0.0"
dependencies:
ci-info: ^3.1.1
bin:
is-ci: bin.js
checksum: 1e26d3ba6634ebee83f9d22f260354c5d950eada4d609c30cc2642069f8ba52f3aeb4c9bbf8099aaf04a2f44a1ed7beef2a24485f988753c8c078a57e9b3a2fd
languageName: node
linkType: hard

"is-color-stop@npm:^1.1.0":
version: 1.1.0
resolution: "is-color-stop@npm:1.1.0"
Expand Down Expand Up @@ -10711,7 +10700,7 @@ __metadata:
languageName: node
linkType: hard

"jest-util@npm:^26.6.2":
"jest-util@npm:^26.1.0, jest-util@npm:^26.6.2":
version: 26.6.2
resolution: "jest-util@npm:26.6.2"
dependencies:
Expand All @@ -10725,20 +10714,6 @@ __metadata:
languageName: node
linkType: hard

"jest-util@npm:^27.0.0":
version: 27.0.6
resolution: "jest-util@npm:27.0.6"
dependencies:
"@jest/types": ^27.0.6
"@types/node": "*"
chalk: ^4.0.0
graceful-fs: ^4.2.4
is-ci: ^3.0.0
picomatch: ^2.2.3
checksum: a62ab3304ad58eb5fa130d66680d987890fca8c0505857a1b8bbcc8cf1de35eb3b82e19bdc5084dd10f68b3ce373234723f57f6e83781d4a4f66be1b647b488d
languageName: node
linkType: hard

"jest-validate@npm:^24.9.0":
version: 24.9.0
resolution: "jest-validate@npm:24.9.0"
Expand Down Expand Up @@ -14561,7 +14536,7 @@ __metadata:
rimraf: ^3.0.2
rollup: ^2.32.1
rollup-plugin-terser: ^7.0.2
ts-jest: ^27.0.3
ts-jest: 26.5.6
typescript: ^4.3.4
peerDependencies:
react: ^16.8.3 || ^17
Expand Down Expand Up @@ -16963,26 +16938,26 @@ __metadata:
languageName: node
linkType: hard

"ts-jest@npm:^27.0.3":
version: 27.0.3
resolution: "ts-jest@npm:27.0.3"
"ts-jest@npm:26.5.6":
version: 26.5.6
resolution: "ts-jest@npm:26.5.6"
dependencies:
bs-logger: 0.x
buffer-from: 1.x
fast-json-stable-stringify: 2.x
jest-util: ^27.0.0
jest-util: ^26.1.0
json5: 2.x
lodash: 4.x
make-error: 1.x
mkdirp: 1.x
semver: 7.x
yargs-parser: 20.x
peerDependencies:
jest: ^27.0.0
jest: ">=26 <27"
typescript: ">=3.8 <5.0"
bin:
ts-jest: cli.js
checksum: a63f3a8620a16335d745f22377a9cc118129d28a5b122c609a7c6aabbb8048c85733c771a0dd39b136e8a75401473409452bdd3c5b9e3b85317c2e3f3ac03267
checksum: fd32a8b256091d45d850c491fd090f74a368d44bccc8fedfa0dd074757727e7f07621eb2a69ebf081428f44a357a879237a2cf0aef970896410d454d0bf87ac6
languageName: node
linkType: hard

Expand Down