title: setting up ts-jest for react typescript project
body: <p>I am trying to setup test environment for a react project written in typescript. I have done it before for react but with ES6.</p>
  
  <p>Following is how the relevant parts of my package.json look like -</p>
  
  <pre><code> "scripts": {
      "test": "NODE_ENV=test jest",
      "build": "webpack --mode production",
      "start": "webpack-dev-server --open --mode development"
    },
    "jest": {
      "moduleNameMapper": {
        "\\.(css)$": "jest-css-modules"
      },
      "transform": {
        "\\.(ts|tsx)$": "ts-jest"
      },
      "testRegex": ".test.(ts|tsx?)$",
      "moduleFileExensions": ["ts", "tsx", "js", "jsx", "json", "node"]
    },
  </code></pre>
  
  <p>I would like to mention that I am counting on ts transpiler and not configured babel at all.</p>
  
  <p>Following are the dependencies I have included -</p>
  
  <pre><code>"dependencies": {
      "@types/jest": "^23.1.4",
      "@types/react": "^16.4.5",
      "@types/react-dom": "^16.0.6",
      "@types/react-redux": "^6.0.3",
      "@types/redux": "^3.6.0",
      "deep-freeze": "0.0.1",
      "jest": "^23.2.0",
      "jest-css-modules": "^1.1.0",
      "react-redux": "^5.0.7",
      "redux": "^4.0.0",
      "ts-jest": "^23.0.0",
      "webpack": "^4.12.2"
    },
    "devDependencies": {
      "awesome-typescript-loader": "^5.2.0",
      "css-loader": "^0.28.11",
      "html-loader": "^0.5.5",
      "html-webpack-plugin": "^3.2.0",
      "prop-types": "^15.6.2",
      "react": "^16.4.1",
      "react-dom": "^16.4.1",
      "style-loader": "^0.21.0",
      "typescript": "^2.9.2",
      "typings-for-css-modules-loader": "^1.7.0",
      "url-loader": "^1.0.1",
      "webpack-cli": "^3.0.8",
      "webpack-dev-server": "^3.1.4"
    }
  </code></pre>
  
  <p>I am unable to understand following error when I run <code>npm run test</code> as I have already installed and specified ts-jest in transform -</p>
  
  <pre><code>Validation Error:
  
    Module ts-jest in the transform option was not found.
           &lt;rootDir&gt; is: /Users/rahul/ot/Lab/webpack-playlist
  </code></pre>
  
  <p>Following is how tsconfig.json looks like</p>
  
  <pre><code>{
    "compilerOptions": {
      "jsx": "react",
      "noImplicitAny": true,
      "sourceMap": true,
      "target": "es5"
    }
  }
  </code></pre>
  
  <p>Not sure how I can I resolve the error above. </p>
  
  <p>I also tried configuring ts-jest in tsconfig.json like below but it still gave same error -</p>
  
  <pre><code>// tsconfig.json
      "jest": {
          "globals": {
            "ts-jest": {
              "tsConfigFile": "tsconfig.jest.json"
            }
          }
        }
  
  
  // tsconfig.jest.json
  {
    "extends": "./tsconfig",
    "compilerOptions": {
      "module": "commonjs"
    }
  }
  </code></pre>