Skip to content

Test our JavaScript with Playwright #585

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

Closed
choldgraf opened this issue Feb 8, 2022 · 4 comments
Closed

Test our JavaScript with Playwright #585

choldgraf opened this issue Feb 8, 2022 · 4 comments

Comments

@choldgraf
Copy link
Collaborator

Description

Currently, we only test things that can be statically-generated by Python, using pytest.

However, a lot of the functionality in this theme comes from JavaScript, which we cannot test simply by looking at the statically-generated HTML files. We currently do not test for interactive things like the dropdown switcher, which makes us more likely to miss regressions and bugs.

Proposed solution

We should investigate using the playwright pytest plugin to do basic "live behavior" testing of important aspects of the theme. playwright can install its own bundled version of chromium and is very well supported.

Here's an example of their pytest plugin in-action from their docs:

# test_my_application.py
def test_example_is_working(page):
    page.goto("https://example.com")
    assert page.inner_text('h1') == 'Example Domain'
    page.click("text=More information")

I think we'd have access to anything in the page object. So for example we could check the inner HTML of a page after it was loaded in chromium. This could let us test for things in a more reliable fashion.

@choldgraf choldgraf changed the title Use playwright to test our JavaScript Test our JavaScript with Playwright Feb 8, 2022
@jorisvandenbossche
Copy link
Member

It would indeed be very good to have such testing. I don't have any experience with this, so if playwright seems a good solution for this, that sounds good to me

@choldgraf
Copy link
Collaborator Author

It is at least what most people on Twitter recommended :-)

@damianavila
Copy link
Collaborator

I agree this would be an improvement!
I also did not know about playwright!
Glad there are alternatives to the whole selenium route...

@drammock
Copy link
Collaborator

drammock commented May 3, 2024

nowadays we use Playwright in our a11y tests, and we've discussed (here and following comments) expanding playwright to testing other aspects of the site too. So I think this can be closed.

@drammock drammock closed this as completed May 3, 2024
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

No branches or pull requests

4 participants