Can't override jest configuration for collectCoverageForm & coverageThreshold in the package.json file

Hi I’m trying to override the jest config in react-app-rewired
this is my jest config in package file:

"jest": {
    "moduleNameMapper": {
      "^@src(.*)$": "<rootDir>/src$1",
      "^@assets(.*)$": "<rootDir>/src/@core/assets$1",
      "^@components(.*)$": "<rootDir>/src/@core/components$1",
      "^@layouts(.*)$": "<rootDir>/src/@core/layouts$1",
      "^@store(.*)$": "<rootDir>/src/redux$1",
      "^@styles(.*)$": "<rootDir>/src/@core/scss$1",
      "^@configs(.*)$": "<rootDir>/src/configs$1",
      "^@utils(.*)$": "<rootDir>/src/utility/Utils$1",
      "^@hooks(.*)$": "<rootDir>/src/utility/hooks$1"
    },
    "setupFilesAfterEnv": [
      "@testing-library/jest-dom/extend-expect",
      "jest-axe/extend-expect"
    ],
    "collectCoverageFrom": [
      "src/views/**/*.js"
    ],
    "coverageThreshold": {
      "global": {
        "branches": 100,
        "functions": 100,
        "lines": 100,
        "statements": -10
      }
    }
  },

is there is a way to add them to the config-overrides.json :

const SassRuleRewire = require("react-app-rewire-sass-rule")
const path = require("path")
const rewireAliases = require("react-app-rewire-aliases")

module.exports = function override(config, env) {
  require("react-app-rewire-postcss")(config, {
    plugins: (loader) => [require("postcss-rtl")()]
  })

  config = rewireAliases.aliasesOptions({
    "@src": path.resolve(__dirname, "src"),
    "@assets": path.resolve(__dirname, "src/@core/assets"),
    "@components": path.resolve(__dirname, "src/@core/components"),
    "@layouts": path.resolve(__dirname, "src/@core/layouts"),
    "@store": path.resolve(__dirname, "src/redux"),
    "@styles": path.resolve(__dirname, "src/@core/scss"),
    "@configs": path.resolve(__dirname, "src/configs"),
    "@utils": path.resolve(__dirname, "src/utility/Utils"),
    "@hooks": path.resolve(__dirname, "src/utility/hooks")
  })(config, env)

  config = new SassRuleRewire()
    .withRuleOptions({
      test: /\.s[ac]ss$/i,
      use: [
        {
          loader: "sass-loader",
          options: {
            sassOptions: {
              includePaths: ["node_modules", "src/assets"]
            }
          }
        }
      ]
    })
    .rewire(config, env)
  return config
}

thanks for your help in advance

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.