【问题标题】:Webdriver.io / wdio.conf.ts: Object literal may only specify known properties, and 'mochaOpts' does not exist in type 'Config'Webdriver.io / wdio.conf.ts:对象字面量只能指定已知属性,而“配置”类型中不存在“mochaOpts”
【发布时间】:2021-01-02 10:05:19
【问题描述】:

我正在关注webdriver io typescript instructions

Object literal may only specify known properties, and 'mochaOpts' does not exist in type 'Config'.

这是由于wdio.conf.ts 包括mochaOpts 以下:

import { Config } from "webdriverio";

const config: Config = {
  //...

  //
  // Options to be passed to Mocha.
  // See the full list at http://mochajs.org/
  mochaOpts: {
    ui: "bdd",
    timeout: 60000,
  },

//...

};

export { config };

有谁知道如何解决这个问题?

【问题讨论】:

  • 您能分享一下您的打字稿设置吗?我看到你在第一行使用导入,这对我不起作用SyntaxError: Cannot use import statement outside a module
  • @Stevy 不知道这是否是正确的做法,但这就是我所拥有的 - ``` { "compileOnSave": false, "compilerOptions": { "target": "ES2020" , "module": "commonjs", "moduleResolution": "node", "strict": true, // NB expect-webdriverio 似乎有助于解决 intellij 视图问题,// 但仍然无法在 intellij 中运行测试不推荐在 docs "types": ["node", "webdriverio/sync", "expect-webdriverio", "@wdio/mocha-framework"] }, "include": ["./test/**/ **.ts", "./wdio.conf.ts" ] } ```

标签: typescript mocha.js webdriver-io


【解决方案1】:

您还需要添加@wdio/mocha-framework 包。

但是,为您的设置配置所有内容的最简单方法是在终端中运行 wdio init 并按照向导进行操作。

如果 wdio 似乎不是一个可识别的命令,您可能需要使用它的相对路径:node_modules/.bin/wdio init

注意:这假设您已经安装了 Nodejs 和 webdriveriowdio 包。

【讨论】:

  • 最后我发现了这个问题 - 我在父目录中有一个额外的tsconfig.json,我认为这有点冲突。当我删除额外的 tsconfig.json 文件时,一切似乎都正常。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-11-27
  • 1970-01-01
  • 2022-08-24
  • 2018-09-06
  • 2021-02-18
  • 2021-09-27
  • 2020-07-19
相关资源
最近更新 更多