Malformed JSON running Jest in IntelliJ IDEA

Viewed 628

I'm trying to setup jest configuration for IntelliJ but I'm getting this error in the IDE Failed to parse Jest config jest.config.js: malformed JSON: enter image description here

However, the tests work in the console:

āžœ  project-web git:(master) āœ— jest --config jest.config.js src/client/components
 PASS  src/client/components/FormInput/index.test.tsx
 PASS  src/client/components/Card/index.test.tsx
 PASS  src/client/components/Button/indext.test.tsx
 PASS  src/client/components/StepsBar/components/Step/Step.test.jsx
 FAIL  src/client/components/Help/index.test.tsx

Whith this IDE configuration: IDE configuration

And jest.config.js:

module.exports = {
  moduleFileExtensions: ["js", "jsx", "ts", "tsx"],
  ["moduleNameMapper"]: {
    // These take care of webpack's alias
    ["^Redux(.*)"]: "<rootDir>/src/client/redux$1",
    ["^Static(.*)"]: "<rootDir>/src/static$1",
    ["^Components(.*)"]: "<rootDir>/src/client/components$1",
    ["^Hoc(.*)"]: "<rootDir>/src/client/hoc$1",
    ["^Services(.*)"]: "<rootDir>/src/client/services$1",
    ["^Constants(.*)"]: "<rootDir>/src/client/constants$1",
    ["^Scenes(.*)"]: "<rootDir>/src/client/scenes$1",
    ["^Types(.*)"]: "<rootDir>/src/client/types",
    ["^Helpers(.*)"]: "<rootDir>/src/client/helpers$1",

    // These take care of imports of non-js assets (which are allowed by
    // webpack, but not by Babel). Will import the object specified in the
    // matching mock file instead of the asset. The object keys act as regex.
    ["\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$"]: "<rootDir>/src/__mocks__/fileMock.js",
    ["\\.(css|less)$"]: "<rootDir>/src/__mocks__/styleMock.js"
    // NOTE: in the regexs above, "\\." means "a literal period" because the two
    // slashes collapse into one.
  },
  // Test files to exclude. Note that node_modules are excluded by default, but
  // because we're overwriting the default array, they must be added again.
  testPathIgnorePatterns: ["<rootDir>/src/build/", "<rootDir>/node_modules/"],

  // Transform functions. Any file matching the following regexs will be
  // transpiled **synchronously** with the specified function.
  transform: {
    ["^.+\\.(js|jsx|ts|tsx)$"]: "<rootDir>/src/build/test/transformer.js"
  },
  testMatch: [
    "**/*.test.(js|jsx|tsx|ts)"
  ],
  modulePaths: ["<rootDir>/src/client/", "<rootDir>/src/static/"],
  setupFiles: ["<rootDir>/test/jestSetup.js"],
  snapshotSerializers: ["enzyme-to-json/serializer"],
}

If I don't set a configuration file in the configuration of the IDE it runs the test with the default configuration and not my jest.config.js file.

Thanks

1 Answers
Related