【问题标题】:Preset jest-puppeteer is invalid预设 jest-puppeteer 无效
【发布时间】:2020-07-19 18:02:46
【问题描述】:

在一个工作笑话 + puppeteer 项目中, 为了使用jest-circus retry feature,我要搬到 jest-circus。 正如记录的那样,我安装了 jest-circus 并设置为跑步者,但我获得了像往常一样运行测试

 Validation Error:

  Preset jest-puppeteer is invalid:

  The "id" argument must be of type string. Received type object
  TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type object
    at validateString (internal/validators.js:112:11)
    at Module.require (internal/modules/cjs/loader.js:842:3)
    at require (internal/modules/cjs/helpers.js:74:18)
    at setupPreset (C:\src\qa-e2e-update-stack\node_modules\jest-config\build\normalize.js:348:14)
    at normalize (C:\src\qa-e2e-update-stack\node_modules\jest-config\build\normalize.js:703:15)
    at readConfig (C:\src\qa-e2e-update-stack\node_modules\jest-config\build\index.js:220:68)
    at async readConfigs (C:\src\qa-e2e-update-stack\node_modules\jest-config\build\index.js:401:26)
    at async runCLI (C:\src\qa-e2e-update-stack\node_modules\@jest\core\build\cli\index.js:203:59)
    at async Object.run (C:\src\qa-e2e-update-stack\node_modules\jest\node_modules\jest-cli\build\cli\index.js:216:37)

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

这是我的 jest.config.js 文件

const fs = require('fs')
reportFolder = "reports"
if (!fs.existsSync(reportFolder)){
    fs.mkdirSync(reportFolder)
}

module.exports = {
    preset: "jest-puppeteer",
    testRunner: "jest-circus/runner",
    setupFilesAfterEnv: [  // NOT setupFiles
        "./configurazioni/custom-configuration.js",
        "./configurazioni/shared-require.js",
        "jest-allure/dist/setup"
    ],
    "reporters": [
        "default",
        ["./node_modules/jest-html-reporter", {
            "pageTitle": "Test Report",
            "includeFailureMsg": true,
            "includeConsoleLog": true,
            "outputPath":"reports/"+new Date().getDate() + "-" +
                (new Date().getMonth() + 1) + "-"
                + new Date().getFullYear()+ "-"
                + new Date().getHours().toString() + "-"
                + (new Date().getMinutes() + 1 ).toString() + "-"
                + (new Date().getSeconds() + 1 ).toString()
                +"-run.html"
        }],
        ["jest-junit", { outputName: "reports/junitreport.xml" }]
    ],
    moduleNameMapper: { 
        '^\\$lib\/(.*)': `<rootDir>/lib/$1`,
    },
};

我没有找到任何讨论我的问题的页面,jest-circus 和 jest-preset 不能共存?

【问题讨论】:

  • 我在没有 jest-circus 的情况下看到了这个错误,所以看起来有些东西坏了

标签: jestjs puppeteer jest-puppeteer


【解决方案1】:

rootDir 在 jest 配置文件中设置不正确时,我遇到了这样的错误。

【讨论】:

    【解决方案2】:

    我建议检查您的节点包是否安装正确。当我的 node_modules 文件夹被删除时,我遇到了同样的问题。

    【讨论】:

      猜你喜欢
      • 2021-10-15
      • 1970-01-01
      • 2019-08-09
      • 2019-04-17
      • 1970-01-01
      • 2020-01-09
      • 2020-06-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多