Skip to content

Support for running WebdriverIO TypeScript tests on Node 20. Fixes #10901#11202

Merged
christian-bromann merged 11 commits intowebdriverio:mainfrom
jan-molak:fix/node20-with-typescript-support
Sep 19, 2023
Merged

Support for running WebdriverIO TypeScript tests on Node 20. Fixes #10901#11202
christian-bromann merged 11 commits intowebdriverio:mainfrom
jan-molak:fix/node20-with-typescript-support

Conversation

@jan-molak
Copy link
Contributor

@jan-molak jan-molak commented Sep 18, 2023

Proposed changes

Enable WebdriverIO to run TypeScript-based test scenarios on Node 20.

This PR is a more targeted variation of #11173 and an improvement on #11178 aimed at resolving #10901.

Apart from fixing the issue, I also propose to introduce improvements to the WebdriverIO pipeline so that we can test integration with Node 20.

In particular, I made the following modifications to WebdriverIO pipeline to help ensure it works with Node 20:

  • CI pipeline extended to run all the unit, integration, and e2e tests on Node 20 (in addition to Node 16 and 18)
  • generate:bidi script improved to work with Node 20
  • smoke tests improved to work with Node 20

To help ensure that WebdriverIO works with TS-Node on Node 20:

  • wdio run command fixed to support TypeScript test suites on Node 20
  • new source maps integration tests to ensure source maps work correctly for both CJS and ESM projects

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

@jan-molak
Copy link
Contributor Author

jan-molak commented Sep 19, 2023

@christian-bromann - I think to fully test wdio run command we'd need a new kind of integration test that spawns the actual wdio process. At the moment testrunner.test.ts takes a shortcut by using the Launcher directly, but that bypasses the run command.

@jan-molak jan-molak marked this pull request as draft September 19, 2023 10:07
@jan-molak jan-molak marked this pull request as ready for review September 19, 2023 11:39
@jan-molak
Copy link
Contributor Author

@christian-bromann, @nextlevelbeard, @erwinheitzman - this PR is ready for your review. As always, your thoughts and feedback are welcome!

"copy": "cd packages/wdio-cli && npm run copy && cd ../../",
"generate": "run-s generate:*",
"generate:bidi": "npx ts-node-esm ./scripts/bidi/index.ts",
"generate:bidi": "node --loader ts-node/esm ./scripts/bidi/index.ts",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought these would be the same 🤔

Copy link
Contributor Author

@jan-molak jan-molak Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought too, but:

  • npx ts-node-esm ./scripts/bidi/index.ts doesn't work on Node 20
  • node --loader ts-node/esm ./scripts/bidi/index.ts works fine (plus has the added benefit of being consistent with the other scripts)

Have a look at generate:bidi failure on Node 20: https://github.com/webdriverio/webdriverio/actions/runs/6228506528/job/16905377436#step:5:65
and then the step behaving correctly after the change from npx to node --loader - https://github.com/webdriverio/webdriverio/actions/runs/6228656361/job/16905779299#step:5:64

I'm not sure where the difference comes from, but it looks like ESM support in Node 20 has changed a lot since 18

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Sep 19, 2023
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jan-molak
Copy link
Contributor Author

@christian-bromann @erwinheitzman - I can confirm WebdriverIO 8.16.12 works well with Node 20 and the latest Serenity/JS - https://github.com/serenity-js/serenity-js-cucumber-webdriverio-template/actions/runs/6276942410 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants