1

1

2

Getting this error when run the test using npx wdio command.

How to resolve this issue. Error: "ts-node/esm/transpile-only 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include shortCircuit: true in the hook's return.

vimuth
  • 5,064
  • 33
  • 79
  • 116
Masud Rana
  • 23
  • 1
  • 3

2 Answers2

5

The simplest way to get this running is to add typescript and ts-node to the project.

npm i -D typescript ts-node

Then npx wdio

I opted not to use the compiler in a WebdriverIO project but then started getting this error after a few weeks. I just added the libraries above rather than try to chase down the config i likely messed up, in order to eliminate the error message.

1

This error started to occur from node version >= 16.17.0 due to some changes in the Experimental ESM Loader Hooks API.

Solution to resolve this error:

  1. Downgrade the node version to 16.16.0 and you will not see this error.
  2. Since you were using appium v2.x with wdio javascript, install dependency ts-node by running the following command:
npm install ts-node --save-dev

Reason

Appium v1.x does not support TypeScript natively, and therefore it does not use the tsconfig.json file. Appium v1.x is based on Node.js, which supports JavaScript natively but does not include TypeScript support out of the box.

Appium v2.x will have better TypeScript support out of the box. The new version of Appium is based on the WebDriver protocol and will be implemented in TypeScript. This means that developers will be able to write tests in TypeScript without having to set up a separate TypeScript compiler or configure TypeScript manually. Using TypeScript and tsconfig in Appium 2.0 brings several benefits, such as better code maintainability and error checking, improved code readability, and better tooling support.

Important Note

This error will not occur if you use Appium v1.x with latest node version (>16.16.0) in the wdio.

Thangaraj
  • 11
  • 3