2017-11-15 10 views
3

내가 IntelliJ에 대한 설정 농담 구성에 노력하고있어하지만 난 IDE Failed to parse Jest config jest.config.js: malformed JSON에서이 오류를 받고 있어요 : enter image description here잘못된 JSON은

그러나, 테스트가 콘솔에서 작동 :

IDE configuration

그리고 jest.config.js :

01이 IDE 구성 파크
➜ 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 

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"], 
} 

IDE 구성에서 구성 파일을 설정하지 않으면 파일이 아닌 jest.config.js 기본 구성으로 테스트가 실행됩니다.

감사

+2

내가 너무이 문제에 봉착했습니다. jest.config.js를 순수 JSON (''module.exports ='''제거) 할 수 있다면 웹 스톰에서 실행할 수 있습니다. 그러나 터미널에서 실행할 수 없습니다. – Steph

+1

플랫폼. 나는 너를 최신 상태로 유지할거야. https://youtrack.jetbrains.com/issue/IDEA-182942 –

답변