score:1

Accepted answer

i uninstalled jest-cli which was 27+ version globally and tried to run from the local dependencies only, it is working for me now.

configured the modulenamewrapper in jest settings for common components

"modulenamemapper": {
  "\\.(jpg|jpeg|png|gif|svg|yaml)$": "<rootdir>/__mocks__/filemock.js",
  "\\.(css|less|scss)$": "<rootdir>/__mocks__/stylemock.js",
  "^common/(.*)$": "<rootdir>/src/common/$1"
},

babel config modified as below:

module.exports = {
  "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
  "plugins": ["const-enum", ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties", { "loose": true }],
    ["@babel/plugin-transform-runtime", { "regenerator": true }],
    ["@babel/plugin-transform-modules-commonjs"],
    "@babel/plugin-syntax-jsx"]
};

dependencies updated:

"ts-jest": "^26.0.0",
"jest": "26.0.1",

tsconfig

{
  "compileroptions": {
    "outdir": "dist",
    "module": "commonjs",
    //"module": "commonjs",
    "target": "es6",
    "lib": ["esnext", "dom", "dom.iterable"],
    "moduleresolution": "node",
    "declaration": false,
    "strict": false,
    "noimplicitany": false,
    "nounusedlocals": true,
    "skiplibcheck": true,
    "esmoduleinterop": true,
    "allowsyntheticdefaultimports": true,
    "experimentaldecorators": true,
    "jsx": "react",
    "downleveliteration": true,
    "importhelpers": true,
    "preserveconstenums": true,
    "removecomments": false,
    "sourcemap": true,
    "baseurl": "src",
    "resolvejsonmodule": true,
    "paths": {
      "common/*": ["common/*"]
    }
  },
  "include": ["./*.ts", "./*.tsx", "src"],
  "exclude": ["node_modules", "dist", "*.js"]
}

score:0

what's the react version? jest still not support react17.


Related Query

More Query from same tag