BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News WebdriverIO 7 Rewritten in Typescript, Released with Improved Lighthouse Integration

WebdriverIO 7 Rewritten in Typescript, Released with Improved Lighthouse Integration

This item in japanese

The browser and mobile automation test framework WebdriverIO recently released a major update. Webdriver IO 7 is now written with TypeScript. TypeScript users may thus need to update their types, while JavaScript users should be largely unaffected. The new version also drops support for Node v10, upgrades the used Cucumber version to v7, and integrates better with Google Lighthouse.

Christian Bromann explained in the release note the reason behind the TypeScript rewrite:

As more and more contributors have joined the project, we’ve noticed that using pure JavaScript can be helpful to keep the entry barrier for contributions low, but that it ultimately decreases the quality of contributions overall. With the growing size of the code in the project, keeping up with all the different types that were thrown around was becoming more difficult for us as core contributors.
[…]
Our hope is that by moving to TypeScript, fewer bugs will be introduced during [the] continued development of the framework. It will help improve the quality of code contributions and the speed of development of certain features. It also brings more confidence in new versions that we ship to the user.
[…]
We have rewritten the complete code base and almost touched all files to add type safety and to fix a lot of bugs on the way.

WebdriverIO TypeScript users may, as a result, enjoy better type support across the API. The TypeScript configuration file tsconfig.json sees a few changes to reflect the changes in the type library. @wdio/sync (v6) should be replaced with webdriverio/sync, and webdriverio with webdriverio/async. In the latter case, the diff would be as follows:

// tsconfig.json
"types": [
"node",
- "webdriverio",
+ "webdriverio/async",
"@wdio/mocha-framework"
],

Custom commands types must now be provided as follows:

declare global {
  namespace  WebdriverIO  {
    interface  Browser  {
      browserCustomCommand:  (arg: number)  =>  void
    }
  }
}

As usual, TypeScript developers will need typescript and ts-node set as devDependencies in the package.json configuration file. WebdriverIO will automatically detect whether the dependencies are installed and compile config and tests. ts-node runs can be configured through environment variables or the wdio config’s autoCompileOpts property.

WebdriverIO 7 drops support for Node v10, with Node v14 becoming the recommended version. The new release also updates the behavior-driven development tool Cucumber version to v7. Cucumber v7, released in December last year, also dropped support for older versions of Node (Node v14 recommended). Cucumber 7 no longer relies on the community-authored @types/cucumber package, being now built with TypeScript and its own set of typings.

WebdriverIO 7 improved integration with Google Lighthouse, which WebdriverIO users can use to run performance tests. WebdriverIO 7 updated Google Lighthouse to the latest version, which features new performance metrics such as Cumulative Layout Shifts or First Input Delay.

Interested readers may review the complete WebDriverIO 7 release article for more information on additional changes and improvements to the project. WebDriverIO is open-source software available under the MIT license. Contributions are welcome via the WebDriverIO contribution guidelines and code of conduct.

Rate this Article

Adoption
Style

BT