Skip to content

Conversation

@Smrtnyk
Copy link
Contributor

@Smrtnyk Smrtnyk commented Apr 11, 2025

I am currently studying current playwright setup in order to understand it fully and to be able to contribute in migration of visual tests to playwright.
Current playwright setup seems overwhelming to me and with too many acrobatics going on in order to write a simple test.
This PR has a goal to reduce the boiler plate needed to write a playwright test by utilizing a pattern called POM (page object model) https://playwright.dev/docs/pom and playwright fixtures https://playwright.dev/docs/test-fixtures.
This makes playwright setup in fabric more playwright idiomatic and in line of how playwright recommends to structure the tests.
As a result there is not need to call setupApp anymore in each test file, it is done automatically in the page fixture now.
You can also see that this PR reduced lines in playwright by almost 100 lines.

Further ideas to simplify playwright setup even more:

  • remove http-server dependency and startup and leverage playwright routes https://playwright.dev/docs/api/class-
    route to intercept the requests to assets and pages directly by playwright.
    This makes tests truly isolated and removes latency between real client-server scenario.
    It also makes tests depending on one dependency less.
    Another issue with http-server approach is that it currently logs deprecation message

     [WebServer] (node:20974) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
     [WebServer] (Use `node --trace-deprecation ...` to show where the warning was created)
    

    It also doesn't seem maintained anymore.

  • use monocart reporter to simplify coverage collection instead of doing complex acrobatics as it is now

  • implement fully typed playwright test
    currently there are lots of type issues in playwright tests not giving proper intellisense and doesn't give all the type safety typescript offers. It should be easy to create global types so we can have full type safety and intellisense

  • Figure out if babel is needed to build or is there a more straightforward way to run playwright tests in watch mode
    maybe playwright already offers watch mode and we don't need to do all the babel magic at all

  • Figure out if we can directly run playwright files from ts instead of building the js files first

@codesandbox
Copy link

codesandbox bot commented Apr 11, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

await page
.locator('textarea')
.type(
.pressSequentially(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

type method is deprecated and pressSequentially is the new recommended one by the docs

@Smrtnyk Smrtnyk force-pushed the refactor()-playwright branch from 86d9ded to edaa327 Compare April 11, 2025 13:04
@asturur
Copy link
Member

asturur commented Apr 12, 2025

This will take forever for me to parse.
The playwright setup has its own logic ( that i don't fully remember, has been written by a coworker of mine @luciemars and then modified by Shaman123 ), i added a test for the purpose of migrating the visual tests there by simply adding code and it already does both node rendering and browser rendering.
Let's pause this and let's evaluate when at least the simple json rendering test have been migrated in playwright

@Smrtnyk
Copy link
Contributor Author

Smrtnyk commented Apr 12, 2025

This will take forever for me to parse. The playwright setup has its own logic ( that i don't fully remember, has been written by a coworker of mine @luciemars and then modified by Shaman123 ), i added a test for the purpose of migrating the visual tests there by simply adding code and it already does both node rendering and browser rendering. Let's pause this and let's evaluate when at least the simple json rendering test have been migrated in playwright

no worries, I will adjust to the current setup then
I just wanted to show an alternative I am using at work and that I am familiar with, because i find it with less code and less thinking when writing a test
we can evaluate this later when more important work is done then

@Smrtnyk
Copy link
Contributor Author

Smrtnyk commented May 17, 2025

I will close this and we can revisit the whole setup later when we have completely migrated from qunit

@Smrtnyk Smrtnyk closed this May 17, 2025
@Smrtnyk Smrtnyk deleted the refactor()-playwright branch May 17, 2025 14:44
@asturur
Copy link
Member

asturur commented May 19, 2025

ok i can imagine this was accumulating issues of merge conflicts.
Let's keep it open so i can read the diffs.

@Smrtnyk
Copy link
Contributor Author

Smrtnyk commented May 21, 2025

I will reopen this with resolved merge conflicts as soon as I am done with all qunit to playwright migration

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.

2 participants