pydata-sphinx-theme icon indicating copy to clipboard operation
pydata-sphinx-theme copied to clipboard

Test our JavaScript with Playwright

Open choldgraf opened this issue 2 years ago • 3 comments

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 avatar Feb 08 '22 20:02 choldgraf

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

jorisvandenbossche avatar Feb 08 '22 22:02 jorisvandenbossche

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

choldgraf avatar Feb 08 '22 23:02 choldgraf

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

damianavila avatar Feb 22 '22 11:02 damianavila

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 avatar May 03 '24 19:05 drammock