debugging WebStorm / Rider -无法调试Jest测试-无法识别的CLI参数:无法识别的选项“testTimeout”

djp7away  于 2023-03-08  发布在  Storm
关注(0)|答案(1)|浏览(322)

我正在使用Jest测试进行一个Vue.js 2.x项目,虽然我可以很好地运行它们,但我根本无法在Rider / WebStorm中调试它们,因为我得到了以下错误(路径缩写...)

/home/me/.nvm/versions/node/v14.21.2/bin/node --require /usr/share/rider/plugins/javascript-impl/helpers/jest-intellij/lib/jest-intellij-stdin-fix.js /home/me/Development/Repositories/my-app/src/MyApp.Web/ClientApp/node_modules/@vue/cli-service/bin/vue-cli-service.js test:unit --runInBand --testTimeout=10000000 --colors --reporters /usr/share/rider/plugins/javascript-impl/helpers/jest-intellij/lib/jest-intellij-reporter.js --verbose --testNamePattern=^VIEW: log-in shows a form where you can log in  --runTestsByPath /home/me/Development/Repositories/MyApp/src/MyApp.Web/ClientApp/tests/unit/views/log-in.spec.js
Debugger listening on ws://127.0.0.1:44527/c71be107-86f0-4e2f-ae31-2ebdd8c8892d
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
● Unrecognized CLI Parameter:

  Unrecognized option "testTimeout".

  CLI Options Documentation:
  https://jestjs.io/docs/en/cli.html

Waiting for the debugger to disconnect...

Process finished with exit code 1

我不知道如何配置/ tweak / change / fix才能让它正常工作。我不能不发送“testTimeout”,因为它不在我的控制之下。
我应该对我的jest-config.json文件做些什么吗?它目前看起来像这样...

{
    "moduleFileExtensions": [
        "js",
        "json",
        "vue"
    ],
    "transformIgnorePatterns": [
        "/node_modules/(?!(core-js/modules/es6.array.filter|another-module|yet-another-module)/)"
    ],
    "modulePathIgnorePatterns": [
        "<rootDir>/.*/__mocks__"
    ],
    "transform": {
        ".*\\.(vue)$": "vue-jest",
        "^.+\\.js$": "<rootDir>/node_modules/babel-jest",
        "\\.(jpg|jpeg|png|gif|webp|svg)$": "<rootDir>/img-test-transformer.js",
        "\\.(eot|otf|svg|ttf|woff|woff2)$": "<rootDir>/font-test-transformer.js",
        "\\.(mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/media-test-transformer.js",
        "\\.(css|styl|less|sass|scss)$": "jest-transform-stub"
    },
    "moduleNameMapper": {
        "\\.(css|less)$": "<rootDir>/__mocks__/style-mock.js",
        "^@/(.*)$": "<rootDir>/src/$1"
    },
    "testResultsProcessor": "./node_modules/jest-junit-reporter",
    "collectCoverage": true,
    "coverageReporters": [
        "json",
        "text-summary",
        "cobertura"
    ],
    "collectCoverageFrom": [
        "src/**/*.{js,vue}",
        "!**/node_modules/**",
        "!**/dist/**"
    ]
}
sshcrbum

sshcrbum1#

不推荐下面的解决方案确实有效,但它让我陷入了一个奇怪的混乱,我的一个文件被错误卡住了,这些错误无法消失。我怀疑不使用Vue CLI选项意味着导入无法正常工作。Rider / WebStorm中的一些东西现在确信它需要以这种方式运行特定的测试文件,而且现在不会被告知其他情况-我只能通过更改文件名来使它正常运行。

原始建议如下...

  • 这不是一个理想的答案,因为它需要每次设置,但是我设法通过转到测试套件的运行配置并在“编辑配置设置”下将“Jest包”设置设置为“jest”而不是“@vue/cli-service”来调试测试,然后这将适用于给定的运行配置(也许...)。您可以通过右键单击代码窗口中的测试运行图标并执行相同的操作来运行单个测试。*

这种方法的缺点是,它似乎会导致其他错误-即“SyntaxError:无法在模块外部使用import语句”开始到处弹出。

相关问题