-
Notifications
You must be signed in to change notification settings - Fork 0
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
Initial Playwright setup #62
Conversation
Just swooping in here to say that this is an epic PR description. I'm gonna get some coffee and settle down to read. |
Code Climate has analyzed commit 7875ad0 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (90% is the threshold). This pull request will bring the total coverage in the repository to 92.8% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments that might be helpful but if not no worries, nothing remotely close to problematic was here to find!
When merged, this PR will resolve ticket CMDCT-4062.
We still need accessibility tests, and more smoke tests. But this is probably sufficient as-is for now.
Hopefully the rest of this comment will prove useful for adding Playwright to SEDS, CARTS, and QMR someday.
Playwright Setup
yarn init
yarn add @playwright/test @axe-core/playwright
playwright
but we opted for@playwright/test
instead. The former exposes only the playwright library, but the latter also includes the test runner bells and whistles. And in fact, if you inspect the yarn.lock file, you will find thatplaywright-core
was included, as a transient dependency.yarn playwright install
"test": "playwright test",
— executes the tests by themselves"test-ui": "playwright test --ui",
— brings up the test runner interface, allowing you to select which tests to run."./tests/*"
to theexclude
list."test:e2e": "cd tests && yarn test && cd -"
&&
is a command separator; the three commands will be run in sequence. Andcd -
navigates to the previous working directory: in this case, the root directoryyarn run test:e2e
from the root directory, but it is nearly as easy tocd tests
yourself first.yarn test
yarn test-ui
hcbs_secrets
)./run update-env
yarn test-ui
command again, if you already closed the Test Runner since the last time.auth.setup.ts
! Which matches the regex in playwright.config.ts.permissions
object includespages: write
andcontents: write
test
job that invokes playwright. Copy this from another app; no changes should be necessary.upload-reports
job that publishes the playwright results. Copy this too; no changes should be needed here either.test
to theneeds
array for thecleanup
job. Github Actions' default behavior is to try to run every job in parallel; theneeds
are how we specify which jobs should be sequential.main
, namedgh-pages
, and push that as-is.upload-reports
job will actually commit test results to this branch, whenever it executes. The branch name isn't magical, but it is the conventional name for these things.gh-pages
branchTEST_ADMIN_USER_EMAIL
and the rest).test
job, under theRun Playwright Tests
step, there will be anenv
map, connecting the new github secrets to the process.env of the test runner. Are the correct secret names being mapped to the correct environment variable names?test_outcome
management in HCBS' deploy.yml. In short: Give the test step an id. Output that step's outcome at the job level. During cleanup, check that outcome, and fail the job if needed.test_outcome
song and dance wouldn't normally be needed; Github automatically fails jobs with non-success outcomes. But we had to set thecontinue-on-error
flag for the test step, overriding Github's normal behavior - otherwise, when tests failed, we would not upload reports.gh-pages
branchgh-pages
branch and see if there were any recent commits deleting old test result folders.MAX_AGE_DAYS
variable in that script, to something less than 30.gh-pages
branch, because that's the branch the action runs on. You can push them tomain
if you like, but it won't make anything happen.test.use({ storageState })
shorthand. The long form — withbrowser.newContext()
,context.newPage()
, andcontext.close()
— will only be necessary when multiple different logins are required within a single test.consts.ts