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

Feat: set up Playwright #2554

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Feat: set up Playwright #2554

wants to merge 6 commits into from

Conversation

angela-tran
Copy link
Member

@angela-tran angela-tran commented Dec 2, 2024

Closes #2533

This PR sets us up to be able to run and write Playwright tests inside containers.

(This is basically a re-do of #2500 with cleaner commits and smaller scope, i.e. this just focuses on getting the needed tooling in place.)

Running

The playwright service added in this PR is to be used for running Playwright tests.

The service uses an image built by Microsoft that has Playwright + dependencies already installed as the base image.

Trying it out
Outside of the devcontainer, run this in a terminal:
docker compose run --rm playwright

You can also start a terminal session in the playwright service by running:

docker compose run --rm playwright /bin/bash

and then you can run the tests and/or run other Playwright commands using that session.

The test will run as headless. A later PR will contain the setup for running in headed mode.

The console output will hopefully tell you the tests passed, and you can view more output under tests/playwright/test-results.

Writing

We do install pytest-playwright into the devcontainer so that when viewing the test code in the devcontainer, we get syntax-highlighting, code completion, etc.

Docs on writing tests

Healthcheck test as a starting point

A test called test_dev_healthcheck is included here just so we have something to run. We can decide later if there's any value in keeping it once other tests are added.

use a base image that already has playwright and its browsers installed
this provides a better dev experience when reading and writing tests
from within the devcontainer
this makes it so they are used any time pytest is invoked from this
directory
since the tests-pytest workflow runs from the root level, it will also
collect Playwright tests if we don't specify the directory.
@angela-tran angela-tran self-assigned this Dec 2, 2024
@github-actions github-actions bot added tests Related to automated testing (unit, UI, integration, etc.) docker Application container, devcontainer, Compose, etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev labels Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

Coverage report

This PR does not seem to contain any modification to coverable code.

@@ -0,0 +1,11 @@
# https://playwright.dev/docs/docker
FROM mcr.microsoft.com/playwright/python:v1.48.0-jammy
Copy link
Member Author

Choose a reason for hiding this comment

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

@thekaveman tried running this setup and ran into an error about needing to use the latest image which is now mcr.microsoft.com/playwright/python:v1.49.0-jammy.

Is there a latest tag we could use? Or maybe it has something to do with the version of pytest-playwright (try to pin it)?

@angela-tran angela-tran marked this pull request as ready for review December 4, 2024 17:24
@angela-tran angela-tran requested a review from a team as a code owner December 4, 2024 17:24
@angela-tran angela-tran marked this pull request as draft December 10, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployment-dev [auto] Changes that will trigger a deploy if merged to dev docker Application container, devcontainer, Compose, etc. tests Related to automated testing (unit, UI, integration, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Figure out a way for developers to run Playwright easily
1 participant