Using Theia Playwright framework

Hi,

I’m trying to use the Theia Playwright framework on the Theia repo but I’m confused on how to use it in my project.
I’m also confused that it’s in the examples folder of Theia repo.
Is it a library/package that can be installed and used just like a regular testing framework or is it just templates we’re supposed to copy and import in the project?
I tried the first and it has not lib folder so I have imports like import { TheiaApp } from "@theia/playwright/src/theia-app"; and configure typescript to compile it.

@Hanksha thank you for the discussion, I believe that all the questions you’ve asked are likely already covered by the documentation at https://github.com/eclipse-theia/theia/tree/master/examples/playwright and the links referenced, including how to get started.

Since it is run against our browser example, we have it under examples.

It is published on npm, there is not need to copy anything over afaik, the idea is to re-use the page objects downstream:

If something is unclear on how to use it in a dowstream project please let us know! :slight_smile:

cc @planger @JonasHelming

@vince-fugnitto Thanks for your reply

I’ve read the documentation and the code in the repo, I don’t really have trouble getting started, I’m able to run it and it works fine. It’s actually unclear to me how to use it in a downstream project because when I yarn add @theia/playwright (or with -D) only the source is included, maybe I’m missing something.

@JonasHelming I don’t think the current documentation is sufficient for downstream applications to easily setup their applications to use playwright, perhaps the following might help:

  • documenting consuming playwright for downstream extensions (potentially add it to the website).
  • providing a sample repository they can use as a reference.
  • creating a new generator template that scaffolds and application and playwright (we can also benefit from running tests against it).

That would be awesome!

Hi @Hanksha,

thank you for raising this issue!

We actually miss to include the compiled sources of this package. I opened a PR to fix that.

Also I opened an issue to improve the documentation. We’ll start working on that soon and update the issue regarding the progress.

2 Likes

Hi @planger

Thanks, much appreciated!

Hi @Hanksha,

The PR mentioned above has been merged (thanks @vince-fugnitto!) and now the compiled sources are available in the nightly builds (next).
Also, we created – for now as a separate repo – a template project:

With that, it should be easier to get started. Can you please test if that works for you? Feel free to give feedback and suggest changes / enhancements!

In the meantime, we’ll improve the doc in Theia on playwright and potentially make this template project available in Theia or even as a yeoman generator as suggested by Vince above.

Thanks!

1 Like

Hi @planger

I can confirm it works on “next”, although using imports like “@theia/playwright/lib/src/theia-app” is a bit weird, I would have expect “@theia/playwright/lib/theia-app” (since technically you don’t need to include /tests in the lib/).

That template repo is a great help, thanks!

I can confirm it works on “next”

Excellent, thanks!

although using imports like “@theia/playwright/lib/src/theia-app” is a bit weird

Yeah, definitely. I’ll just need to improve the exports of the playwright package. But this would require another change in Theia and I wanted to confirm whether it works in principle first.
I’ll improve that.

1 Like

Hi @Hanksha,

We’ve now updated the project template that’s based on the properly exported page objects.
Please let me know if that works for you as expected.
If yes, I’ll continue working on bringing that to Theia and update the documentation accordingly.

Thanks!

Hi @planger

Thanks, that’s great!

I was able to create a dozen tests and so far the framework has be really useful and stable, I’m now working on running the tests on CI.

I’ll try the template tomorrow and let you know if it’s working for me.

@planger I was able to run the template project and use the latest @next in my project with the proper @theia/playwright imports. All good.

1 Like

@planger is it possible to use it with the latest playwright version or better stick with the version used by the Theia Playwright framework?

I just gave it a quick try locally with the latest version 1.21.1 and all tests passed. So it seems to be working fine if you replace 1.17.1 with the latest version.

But let’s see what the CI says, I’ve opened a draft PR.

Nice, thanks @planger!

Confirmed, 1.21.1 seems to run fine also in the CI.

1 Like

Great!