Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/webdriverio/codemod

A codemod to transform Protractor into WebdriverIO tests
https://github.com/webdriverio/codemod

Last synced: 11 days ago
JSON representation

A codemod to transform Protractor into WebdriverIO tests

Lists

README

        

WebdriverIO Codemod [![Test](https://github.com/webdriverio/protractor-codemod/actions/workflows/test.yaml/badge.svg)](https://github.com/webdriverio/protractor-codemod/actions/workflows/test.yaml)
===================

This project contains various codemods to help migrating from either one major WebdriverIO version to another or from a specific framework to WebdriverIO. It can be used with [jscodeshift](https://www.npmjs.com/package/jscodeshift) and currently supports the following migrations:

- [x] v5 ▶️  v6 (see [migration guide](https://webdriver.io/docs/v6-migration))
- [x] v6 ▶️  v7 (see [migration guide](https://webdriver.io/docs/v7-migration))
- [x] Protractor ▶️  WebdriverIO (see [migration guide](https://webdriver.io/docs/protractor-migration))
- [x] Sync ▶️  Async (see [migration guide](https://webdriver.io/docs/async-migration))
- Note: This codemod depends on the [proxying of chained async calls](https://webdriver.io/blog/2021/07/28/sync-api-deprecation/) added in v7.9
- [ ] _more will eventually follow, let us know which ones you would like to see_

If you run into any issues during your migration please [let us know](https://github.com/webdriverio/codemod/discussions/new).

## Install

To transform your spec files, you need to install the following packages:

```sh
$ npm install jscodeshift @wdio/codemod
```

## Usage

To transform you code, run:

```sh
$ npx jscodeshift -t ./node_modules/@wdio/codemod/
# e.g. to migrate from v5 to v6
$ npx jscodeshift -t ./node_modules/@wdio/codemod/v6 ./e2e/
# e.g. to migrate from v6 to v7:
$ npx jscodeshift -t ./node_modules/@wdio/codemod/v7 ./e2e/
# e.g. to transform Protractor code:
$ npx jscodeshift -t ./node_modules/@wdio/codemod/protractor ./e2e/
# e.g. to tranform from sync to async
$ npx jscodeshift -t ./node_modules/@wdio/codemod/async ./e2e/
```

If you use TypeScript make sure you apply a different parser as parameter, e.g.:

```sh
$ npx jscodeshift -t ./node_modules/@wdio/codemod/protractor --parser=tsx ./e2e/*.ts
```

If you use a different line terminator from your os, you can override it as parameter, e.g.:

```sh
$ npx jscodeshift -t ./node_modules/@wdio/codemod/async --printOptions='{\"lineTerminator\":\"\n\"}' ./e2e/
```

You can transform tests as well as config files, e.g.:

![Codemod Usage Example][example]

[example]: /.github/assets/example.gif "Codemod Usage Example"