Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(testing): adding WebdriverIO docs #1346

Merged
merged 32 commits into from
Feb 13, 2024

Conversation

christian-bromann
Copy link
Member

@christian-bromann christian-bromann commented Feb 5, 2024

This patch adds docs on top of the docs-reorg PR for WebdriverIO Testing.

In the docs you will see that I am trying to get some basic docs in place but mostly reference to the WebdriverIO project docs.

@christian-bromann christian-bromann requested a review from a team as a code owner February 5, 2024 22:44
@christian-bromann christian-bromann requested review from rwaskiewicz and alicewriteswrongs and removed request for a team February 5, 2024 22:44
Copy link

vercel bot commented Feb 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stencil-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2024 1:01am

@rwaskiewicz
Copy link
Contributor

Adding the rest of the team here - I encourage everyone to run through these instructions on your machine. Please play with the docs + examples here as if you were an end user attempting to use WebdriverIO and use that to drive feedback

Copy link
Contributor

@alicewriteswrongs alicewriteswrongs left a comment

Choose a reason for hiding this comment

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

some questions and comments!

docs/testing/01-overview.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/01-overview.md Outdated Show resolved Hide resolved

- __Cross Browser Support__: WebdriverIO is designed to support all platforms, either on desktop or mobile. You can run tests on actual browser your users are using, including covering different versions of them.
- __Real User Interaction__: Interacting with elements in WebdriverIO through the WebDriver protocol is the closes you can get to reality compared to emulated interaction in virtual DOM environments.
- __Web Platform Support__: Running tests in actual browser allows you to tap into the latest Web Platform features for testing your components, often not available when using virtual DOM environments.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- __Web Platform Support__: Running tests in actual browser allows you to tap into the latest Web Platform features for testing your components, often not available when using virtual DOM environments.
- __Web Platform Support__: Running tests in actual browsers allows you to tap into the latest Web Platform features for testing your components, often not available when using virtual DOM environments.

should we maybe highlight that this keeps polyfills out of the picture, i.e. if you test an integration with a given DOM API you're testing the integration with an actual browser engine and not the integration with however it's implemented in JSDom (which could be anything from quite close to standards-compliant to way, way off)

Copy link
Member Author

Choose a reason for hiding this comment

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

add a 4th point>

  • Real Environments: Run your tests in an environment that your users are using and not somewhere that re-implements web standards with polyfills like JSDOM.

To get started with WebdriverIO, all you need to do is to run their project starter:

```sh
npm init wdio@latest .
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fun haha

Screenshot 2024-02-07 at 2 17 46 PM

npm run wdio
```

More information on setting up WebdriverIO can be found in their [documentation](https://webdriver.io/docs/component-testing/stencil).
Copy link
Contributor

Choose a reason for hiding this comment

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

I was able to stand up a new project easily with npm init wdio@latest and so on and faced no issues, however when I tried to add webdriverio stuff to an existing project I faced a bit of an issue.

I first created a new test stencil project like so:

mkdir /tmp/test && cd /tmp/test
npm init stencil component test-adding-wdio

then after doing an npm install and whatnot I ran:

npm init wdio@latest .

this ran through the wizard with no problems, and it looks like it cleanly installed things over my existing setup, but then when I try npm run wdio I get:

Screenshot 2024-02-07 at 2 26 36 PM

I then went to install ts-node and then get a different error:

Screenshot 2024-02-07 at 2 27 26 PM

I have no idea what I'm doing with wdio so probably missing something! But j/w two things:

  • is adding wdio tests to an existing project using the init starter something that's supported?
  • if so, is that something we should document here?

I imagine there's going to be some interest in using this approach for the e2e tests in existing projects, so we might want to make sure that's documented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Two errors happened here which are bad DX and a bug in WebdriverIO:

  • first, currently WebdriverIO assumes ts-node to be installed for all TypeScript projects, this assumption is wrong though. I raised an issue in the WebdriverIO project and can tackle this quickly.
  • second, the config is written in ESM while a new Stencil project is set up as CJS project - it is currently very difficult to find out what environment the project is set up with but this is DX I can also fix on the WebdriverIO side - in the meantime, let me add a comment to rename the config to .mts

Copy link
Contributor

Choose a reason for hiding this comment

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

I ran into this as well - would renaming the config extension to .mts work? I tried that locally and ran into issues there:

ERROR @wdio/config:ConfigParser: Failed loading configuration file: file:///private/tmp/wdio-basic-test/wdio.conf.ts: Cannot find module '/private/tmp/wdio-basic-test/wdio.conf.ts' imported from /private/tmp/wdio-basic-test/node_modules/@wdio/config/build/node/RequireLibrary.js
Error: Cannot find module '/private/tmp/wdio-basic-test/wdio.conf.ts' imported from /private/tmp/wdio-basic-test/node_modules/@wdio/config/build/node/RequireLibrary.js
    at finalizeResolution (/private/tmp/wdio-basic-test/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:366:11)
    at moduleResolve (/private/tmp/wdio-basic-test/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:801:10)
    at Object.defaultResolve (/private/tmp/wdio-basic-test/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:912:11)
    at /private/tmp/wdio-basic-test/node_modules/ts-node/src/esm.ts:218:35
    at entrypointFallback (/private/tmp/wdio-basic-test/node_modules/ts-node/src/esm.ts:168:34)
    at /private/tmp/wdio-basic-test/node_modules/ts-node/src/esm.ts:217:14
    at addShortCircuitFlag (/private/tmp/wdio-basic-test/node_modules/ts-node/src/esm.ts:409:21)
    at resolve (/private/tmp/wdio-basic-test/node_modules/ts-node/src/esm.ts:197:12)
    at nextResolve (node:internal/modules/esm/hooks:865:28)
    at Hooks.resolve (node:internal/modules/esm/hooks:303:30)

Wouldn't the config file need to be a CJS module? Or am I misunderstanding the issue here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@rwaskiewicz I think you missed to update the wdio script in the package.json which still points to a wdio.conf.ts file. I tested it and changing to .mts works. The problem is that the Stencil starter project is a CJS project unless you do either of the two changes:

  • rename wdio.conf.ts to wdio.conf.mts (my preferred choice)
  • add "type": "module" to package.json (related to work proposed in STENCIL-1051)

The other option is to have WebdriverIO compose the whole thing as CJS (use require instead import) but that sounds like a step backwards to me.

I will add an admonition telling users to make this change, and check the ESM state of their project as I think this is the easiest way to unblock this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the following two admonitions:

Screenshot 2024-02-08 at 6 27 20 PM

The example component generated by WebdriverIO uses fragments which causes TypeScript to fail due to missing jsxFragmentFactory settings. I left this out as it seems straightforward how to fix it and chances are that users either don't generate them or remove them immediately. Let me know if I should add an admonition for this too.

docs/testing/webdriverio/03-mocking.md Outdated Show resolved Hide resolved
Copy link
Member

@tanner-reits tanner-reits left a comment

Choose a reason for hiding this comment

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

Content looks good! Just some grammatical stuff and marked a few spots to use npm2yarn


:::info

Missing an `await` can be a simple oversight and can cause us long hours of debugging. To avoid this and ensure promises are handled properly, it is recommended to use an ESLint rule called [`require-await`](https://eslint.org/docs/latest/rules/require-await).
Copy link
Member

Choose a reason for hiding this comment

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

Ooh nice, we'll wanna recommend this in Playwright too. Sean said Framework has a lint rule, but idk if they used a published rule or rolled their own.

docs/testing/webdriverio/03-mocking.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/01-overview.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/01-overview.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/04-visual-testing.md Outdated Show resolved Hide resolved
Copy link
Contributor

@rwaskiewicz rwaskiewicz left a comment

Choose a reason for hiding this comment

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

Nice! I had a few comments/asks, most of which are minor little nitpicks.

One more general ask - it's not clear to me from the documentation how well WebdriverIO (or any other testing framework) would integrate with npx stencil test out of the box. Can we add a blurb somewhere that explains/answers:

  • "Should I continue using npx stencil test?"
  • "How do existing tests integrate with my existing Stencil setup?"

docs/testing/webdriverio/01-overview.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/_category_.json Outdated Show resolved Hide resolved
docs/testing/01-overview.md Show resolved Hide resolved
docs/testing/webdriverio/01-overview.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/01-overview.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/02-unit-testing.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/02-unit-testing.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/02-unit-testing.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/02-unit-testing.md Outdated Show resolved Hide resolved
docs/testing/webdriverio/04-visual-testing.md Outdated Show resolved Hide resolved
christian-bromann and others added 23 commits February 12, 2024 16:57
@christian-bromann christian-bromann merged commit e24feec into cb/testing-docs-reorg Feb 13, 2024
5 checks passed
@christian-bromann christian-bromann deleted the cb/wdio-docs branch February 13, 2024 16:27
christian-bromann added a commit that referenced this pull request Feb 13, 2024
…#1344)

* docs(testing): re-organize testing up to allow adding more frameworks

* prettier

* fix wording

* fix links

* Update docs/testing/stencil-testrunner/02-config.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* fixed json formatting

* fixed wording

* Update docs/testing/01-overview.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* deprecate visual diff capabilities

* prettier

* Revert "deprecate visual diff capabilities"

This reverts commit f91757d.

* Update docs/testing/01-overview.md

Co-authored-by: Alice Pote <[email protected]>

* Update docs/testing/01-overview.md

Co-authored-by: Tanner Reits <[email protected]>

* Update docs/testing/stencil-testrunner/01-overview.md

Co-authored-by: Tanner Reits <[email protected]>

* Update docs/testing/stencil-testrunner/03-unit-testing.md

Co-authored-by: Tanner Reits <[email protected]>

* docs(testing): adding WebdriverIO docs (#1346)

* docs(testing): adding WebdriverIO docs

* add webdriverio to cspell list

* add visual docs

* minor wording

* prettier update

* Update docs/testing/webdriverio/01-overview.md

Co-authored-by: Alice Pote <[email protected]>

* fix example

* Update docs/testing/webdriverio/03-mocking.md

Co-authored-by: Tanner Reits <[email protected]>

* Update docs/testing/webdriverio/01-overview.md

Co-authored-by: Tanner Reits <[email protected]>

* use npm2yarn

* fix admonition

* pr feedback

* Update docs/testing/webdriverio/01-overview.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* Update docs/testing/webdriverio/01-overview.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* Update docs/testing/webdriverio/04-visual-testing.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Ryan Waskiewicz <[email protected]>

* add description on what a service is

* added a section on integration with Stencil testing capabilities

* minor tweak to code example

* add section on components list

* add admonition

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Alice Pote <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Alice Pote <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Alice Pote <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Alice Pote <[email protected]>

* Update docs/testing/webdriverio/02-unit-testing.md

Co-authored-by: Alice Pote <[email protected]>

* fix code example meeting

* add note how to run both test runners

---------

Co-authored-by: Alice Pote <[email protected]>
Co-authored-by: Tanner Reits <[email protected]>
Co-authored-by: Ryan Waskiewicz <[email protected]>

* use code references for Screenshot connector

---------

Co-authored-by: Ryan Waskiewicz <[email protected]>
Co-authored-by: Alice Pote <[email protected]>
Co-authored-by: Tanner Reits <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants