diff --git a/README.md b/README.md index c4206a4030..bba98092a7 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,27 @@ If you *have* explicitly set the `module` property but to a different value than If you use ["baseUrl"](https://www.typescriptlang.org/docs/handbook/module-resolution.html) and "paths" options for the compiler, see ["moduleNameMapper"](https://facebook.github.io/jest/docs/en/configuration.html#modulenamemapper-object-string-string) option on Jest docs. +For example, with the below config in your tsconfig: +``` + "paths": { + "@App/*": [ + "src/*" + ], + "@Shared/*": [ + "src/Shared/*" + ] + }, +``` + +Here's what your jest config should look like: + +``` +"moduleNameMapper": { + "@App/(.*)": "/src/$1", + "@Shared/(.*)": "/src/Shared/$1" +} +``` + ### Skipping Babel If you don't use mocks, or synthetic default imports you can skip the babel-transpilation step. This means `jest.mock()` calls will not be hoisted to the top, diff --git a/package.json b/package.json index b6e7261ac2..8b1a3cf3aa 100644 --- a/package.json +++ b/package.json @@ -68,19 +68,14 @@ }, "dependencies": { "closest-file-data": "^0.1.4", - "cpx": "^1.5.0", "fs-extra": "6.0.1", - "jest-config": "^23.4.1", - "lodash": "^4.17.10", - "pkg-dir": "^3.0.0", - "yargs": "^12.0.1" + "lodash": "^4.17.10" }, "peerDependencies": { - "babel-core": "^7.0.0-0", - "babel-jest": "^23.0.0", - "@babel/preset-env": "^7.0.0", - "jest": "^23.0.0", - "typescript": "2.x" + "babel-core": "^6.0.0 || ^7.0.0-0", + "babel-jest": "^23.0.0 || ^24.0.0", + "jest": "^23.0.0 || ^24.0.0", + "typescript": "^2.0.0 || ^3.0.0" }, "devDependencies": { "@babel/core": "^7.0.0-beta.54", @@ -90,24 +85,29 @@ "@types/fs-extra": "5.0.4", "@types/jest": "^23.3.0", "@types/lodash": "^4.14.109", - "@types/node": "10.5.2", + "@types/node": "10.5.5", "@types/react": "16.4.7", "@types/yargs": "^11.0.0", "babel-jest": "^23.4.0", "babel-preset-jest": "^23.2.0", + "babel-core": "^7.0.0-0", + "cpx": "^1.5.0", "cross-spawn": "latest", "cross-spawn-with-kill": "latest", "doctoc": "latest", "husky": "^0.14.3", "jest": "^23.4.1", + "jest-config": "^23.4.1", "lint-staged": "^7.1.2", + "pkg-dir": "^3.0.0", "prettier": "^1.12.1", "react": "16.4.1", "react-test-renderer": "16.4.1", "reflect-metadata": "^0.1.12", "rimraf": "^2.6.2", "tslint": "^5.11.0", - "typescript": "^2.9.2" + "typescript": "^2.9.2", + "yargs": "^12.0.1" }, "lint-staged": { "*.js": [ diff --git a/yarn.lock b/yarn.lock index b36a6fdfcb..5c45a2fba7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -582,13 +582,13 @@ version "8.0.31" resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.31.tgz#d9af61093cf4bfc9f066ca34de0175012cfb0ce9" -"@types/node@10.5.2": - version "10.5.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.2.tgz#f19f05314d5421fe37e74153254201a7bf00a707" +"@types/node@10.5.5": + version "10.5.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.5.tgz#8e84d24e896cd77b0d4f73df274027e3149ec2ba" -"@types/react@16.4.6": - version "16.4.6" - resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.6.tgz#5024957c6bcef4f02823accf5974faba2e54fada" +"@types/react@16.4.7": + version "16.4.7" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.7.tgz#f33f6d759a7e1833befa15224d68942d178a5a3f" dependencies: csstype "^2.2.0" @@ -854,6 +854,10 @@ babel-core@^6.0.0, babel-core@^6.26.0: slash "^1.0.0" source-map "^0.5.6" +babel-core@^7.0.0-0: + version "7.0.0-bridge.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece" + babel-generator@^6.18.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.0.tgz#ac1ae20070b79f6e3ca1d3269613053774f20dc5"