Skip to content

Commit

Permalink
feat(ts/jest): move jest config to ts file (#2542)
Browse files Browse the repository at this point in the history
* feat(ts/jest): move jest config to ts file

* fix: add ts-node for jest ts config file
  • Loading branch information
firestack authored Apr 18, 2024
1 parent 850bbe1 commit 6410fd2
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 38 deletions.
31 changes: 31 additions & 0 deletions assets/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Config } from "jest"

const config: Config = {
testEnvironment: "jsdom",
clearMocks: true,
transform: {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": [
"ts-jest",
{
tsconfig: "./tsconfig.test.json",
},
],
},
transformIgnorePatterns: [
"/node_modules/(?!(@react-leaflet|react-leaflet|screenfull)/)",
],
testRegex: "(src|tests)/.*\\.test\\.tsx?$",
modulePaths: ["<rootDir>/src"],
moduleFileExtensions: ["js", "json", "jsx", "node", "ts", "tsx"],
moduleNameMapper: {
"\\.(svg)$": "<rootDir>/tests/testHelpers/svgStubber.js",
"\\.(css|less)$": "identity-obj-proxy",
},
setupFilesAfterEnv: ["<rootDir>/tests/setup.tsx"],
collectCoverage: true,
globalSetup: "./tests/global-setup.js",
preset: "ts-jest/presets/js-with-babel",
}

export default config
126 changes: 126 additions & 0 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 1 addition & 38 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,47 +107,10 @@
"testing-library-selector": "^0.2.1",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.4",
"ts-node": "^10.9.2",
"typescript": "^5.1.6",
"typescript-language-server": "^4.1.3",
"webpack": "^5.76.2",
"webpack-cli": "^5.0.1"
},
"jest": {
"testEnvironment": "jsdom",
"clearMocks": true,
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": [
"ts-jest",
{
"tsconfig": "./tsconfig.test.json"
}
]
},
"transformIgnorePatterns": [
"/node_modules/(?!(@react-leaflet|react-leaflet|screenfull)/)"
],
"testRegex": "(src|tests)/.*\\.test\\.tsx?$",
"modulePaths": [
"<rootDir>/src"
],
"moduleFileExtensions": [
"js",
"json",
"jsx",
"node",
"ts",
"tsx"
],
"moduleNameMapper": {
"\\.(svg)$": "<rootDir>/tests/testHelpers/svgStubber.js",
"\\.(css|less)$": "identity-obj-proxy"
},
"setupFilesAfterEnv": [
"<rootDir>/tests/setup.tsx"
],
"collectCoverage": true,
"globalSetup": "./tests/global-setup.js",
"preset": "ts-jest/presets/js-with-babel"
}
}

0 comments on commit 6410fd2

Please sign in to comment.