This repository has been archived by the owner on Jan 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 492
Question: Is there any way to use local jest configuration ? #396
Comments
I just encountered this problem as well, but I'm using Microsoft's repo. |
Hey @somarlyonks! Just change your npm task for running "test": "jest --no-cache -w 2", And don't forget to add some extra rules into your jest config (or package.json). E.g. my jest config: "jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!**/*.d.ts",
"!**/*.test.api.ts"
],
"setupFiles": [
"<rootDir>/config/jest/setup.js",
"<rootDir>/config/polyfills.js",
"jest-localstorage-mock"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.ts?(x)",
"<rootDir>/src/**/?(*.)(spec|test).ts?(x)"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.tsx?$": "ts-jest",
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$"
],
"moduleNameMapper": {
"^.+\\.css$": "identity-obj-proxy",
"^react-native$": "react-native-web",
"^src/([^\\.]*)$": "<rootDir>/src/$1"
},
"moduleFileExtensions": [
"web.ts",
"ts",
"web.tsx",
"tsx",
"web.js",
"js",
"web.jsx",
"jsx",
"json",
"node",
"mjs"
],
"globals": {
"ts-jest": {
"tsConfig": "./tsconfig.test.json"
}
},
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
}, Please let me know if you will have any problems. 😉 |
@r3nya Thanks a lot. It works. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Is this a bug report?
No
I mean, a
jest.config.js
in rootDir, it looks like thecreateJestConfig
just ignore the local configuration, and if I run it withreact-scripts-ts test --coverage --config=jest.config.js --env=jsdom
It complains that
argv.config.match is not a function
.Env
node 8.10
dependecies
The text was updated successfully, but these errors were encountered: