Skip to content

WebdriverIO project generator for Serenity/JS#11368

Merged
christian-bromann merged 14 commits intowebdriverio:mainfrom
jan-molak:features/serenity-js-project-generator
Oct 12, 2023
Merged

WebdriverIO project generator for Serenity/JS#11368
christian-bromann merged 14 commits intowebdriverio:mainfrom
jan-molak:features/serenity-js-project-generator

Conversation

@jan-molak
Copy link
Contributor

Proposed changes

Per my discussion with @christian-bromann, I'd like to extend the WebdriverIO project wizard to generate Serenity/JS projects, too.

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 jan-molak marked this pull request as draft October 9, 2023 10:48
@jan-molak jan-molak changed the title WebdriverIO project wizard can now generate Serenity/JS projects too WebdriverIO project generator for Serenity/JS Oct 9, 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.

This PR seems to only contains improvements for unit tests and some wording. No signs of Serenity in here. If this is intentional, let's go ahead and merge this as it a good patch itself.

LGTM 👍

@jan-molak
Copy link
Contributor Author

@christian-bromann - I'm adding Serenity now :)

@jan-molak
Copy link
Contributor Author

jan-molak commented Oct 10, 2023

@christian-bromann - I added project generators for Serenity/JS with Cucumber, Jasmine, and Mocha. Please let me know if you're happy with the overall structure and integration points.

I've tested this extensively manually by generating a project with each of the 3 runners and each runner using TS, CJS, ESM, or Babel, but I need to think about automated tests I could write to ensure that the EJS template rendering works as expected. Maybe snapshot tests could do the trick here, as there are quite a few template files involved.

@jan-molak jan-molak marked this pull request as ready for review October 10, 2023 00:28
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.

One comment, otherwise LGTM

What do you think @erwinheitzman @tamil777selvan ?

Copy link
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@tamil777selvan tamil777selvan left a comment

Choose a reason for hiding this comment

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

I have a minor suggestion. Could we have a single template instead of both js.ejs and ts.ejs as like we currently have?

@jan-molak
Copy link
Contributor Author

I have a minor suggestion. Could we have a single template instead of both js.ejs and ts.ejs as like we currently have?

That's a good idea; I'll need to introduce some helpers to avoid having to repeat if statements.

@jan-molak
Copy link
Contributor Author

@christian-bromann and @tamil777selvan - thanks for your feedback. I merged WebdriverIO and Serenity/JS configuration templates. I've also removed separate templates for CJS/ESM and instead generate TS, CJS and ESM from TypeScript templates.

Serenity/JS code sample templates are reasonably involved as they contain classes, functions, interfaces, parameters, return types, and so on. To avoid polluting WDIO EJS templates with a bazillion if statements, I introduced an EjsHelpers class that helps to generate different kinds of files from the same TS file.

The best example of using the helpers can be seen at https://github.com/webdriverio/webdriverio/pull/11368/files#diff-d2b3a22b9c707586c3011b43acc439b12e3c952a0bf5f70f58cf257558406908

You'll also find unit tests demonstrating the behaviour of EjsHelpers at https://github.com/webdriverio/webdriverio/pull/11368/files#diff-99bb565c721ebef00c7ccea7cab374547e3c4a25a78d03a0e321c888aaefec5c

I think I've arrived at quite an elegant solution that could be used to simplify other WDIO templates too if needed.

Looking forward to hearing your thoughts!

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 👍

Great work!

@christian-bromann christian-bromann added the PR: New Feature 🚀 PRs that contain new features label Oct 11, 2023
Copy link
Member

@tamil777selvan tamil777selvan left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@christian-bromann christian-bromann merged commit 68bde99 into webdriverio:main Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: New Feature 🚀 PRs that contain new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants