Search code examples
typescriptmocha.jswebdriver-io

Webdriver.io / wdio.conf.ts: Object literal may only specify known properties, and 'mochaOpts' does not exist in type 'Config'


I'm following the webdriver io typescript instructions

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

This is due wdio.conf.ts including mochaOpts following:

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 };

Does anyone know how to fix this?


Solution

  • You need to also add the @wdio/mocha-framework package.

    However, the easiest way to configure everything for your setup would be to run wdio init in your terminal and follow the wizard.

    If wdio seems not to be as a recognisable command you may need to use the relative path to it: node_modules/.bin/wdio init

    NOTE: This assumes you have installed the Nodejs and the webdriverio, wdio packages.