gpt4 book ai didi

intellij-idea - 在 IntelliJ IDEA 中运行 Jest 的格式错误的 JSON

转载 作者:行者123 更新时间:2023-12-02 01:06:31 25 4
gpt4 key购买 nike

我正在尝试为 IntelliJ 设置 jest 配置,但我在 IDE 中收到此错误 Failed to parse Jest config jest.config.js: malformed JSON: enter image description here

但是,测试在控制台中运行:

➜  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

使用此 IDE 配置: IDE configuration

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

如果我没有在 IDE 配置中设置配置文件,它会使用默认配置运行测试,而不是我的 jest.config.js 文件。

谢谢

最佳答案

这已在 IDE Intellij 2017.3 中修复

我用的是2017.2.6

在这里回答:https://youtrack.jetbrains.com/issue/IDEA-182942

关于intellij-idea - 在 IntelliJ IDEA 中运行 Jest 的格式错误的 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47309230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com