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

Set up Playwright screenshot testing #612

Merged
merged 19 commits into from
Oct 14, 2022
Merged

Set up Playwright screenshot testing #612

merged 19 commits into from
Oct 14, 2022

Conversation

EthanThatOneKid
Copy link
Owner

@EthanThatOneKid EthanThatOneKid commented Oct 12, 2022

What we can do now

npm t has now been upgraded to include parallelized Playwright tests and screenshot diff testing. To specifically test the Playwright tests and not the Vitest tests, you may run npm run test:browser. Make some changes on screenshot-tested pages and give it a try!

npm t

Change log

  • Split up /tests/test.ts tests into each page of the /src/routes/ directory.
  • Added projectsFromMatrix helper to generate a matrix of screenshots to be taken per page.
  • Added vitest.config.ts to exclude Playwright tests from the Vitest testing.
  • Generated the first official set of screenshots in /src/routes/screenshots/.
  • This PR goes on to add the screenshot testing boilerplate for each page endpoint of the website.
    • Added screenshot tests for 404 error page.
    • Added screenshot tests for /1st page.
    • Added screenshot tests for /about page.
    • Added screenshot tests for /blog page.
    • Added screenshot tests for /blog/:id page.
    • Added screenshot tests for /events page.
    • Added screenshot tests for /nodebuds page.
    • Added screenshot tests for /privacy page.
    • Added screenshot tests for /quiz page.
    • Added screenshot tests for /teams page.

Resolves #557.

@vercel
Copy link

vercel bot commented Oct 12, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
acm-csuf-site ✅ Ready (Inspect) Visit Preview Oct 14, 2022 at 7:51AM (UTC)

And added testing for `/blog/272`.
@vercel vercel bot temporarily deployed to Preview October 12, 2022 04:05 Inactive
Also, slightly refactored `src\routes\(site)\about\officer-profile.svelte` to remove unused code.
And removed threshold of 0.1 since the default of 0.2 should be better. If not, we should bump it up to 0.3.
Added waitFor: 'network-idle' in an attempt to wait for the JS to load.

Also removed tests for blog page since there is currently no way of running the Playwright tests with DEBUG_MODE_ENABLED sadly.
Replaced threshold with a starting `maxDiffPixelRatio: 0.1` and a lax threshold of `threshold: 1`.
@vercel vercel bot temporarily deployed to Preview October 12, 2022 19:47 Inactive
@EthanThatOneKid EthanThatOneKid marked this pull request as ready for review October 12, 2022 19:48
@anguzz
Copy link
Collaborator

anguzz commented Oct 12, 2022

HUGE 🧠

package.json Outdated Show resolved Hide resolved
This kinda took way too long to test :/
BUT screenshot tests are cool and convenient.
@vercel vercel bot temporarily deployed to Preview October 13, 2022 03:57 Inactive
@vercel vercel bot temporarily deployed to Preview October 13, 2022 04:04 Inactive
@vercel vercel bot temporarily deployed to Preview October 13, 2022 04:44 Inactive
- Mobile matches Samsung Galaxy S7 Edge
- Tablet matches Samsung Galaxy Tab 10
@vercel vercel bot temporarily deployed to Preview October 13, 2022 05:00 Inactive
@vercel vercel bot temporarily deployed to Preview October 13, 2022 05:05 Inactive
@EthanThatOneKid
Copy link
Owner Author

This PR is intended to introduce a new feature as a trial run. If the new feature (Playwright screenshot testing) works out to be more of a hinderance than a convenience, then I will remove this feature sometime near the end of the Fall 2022 semester.

Copy link
Collaborator

@karnikaavelumani karnikaavelumani left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jaasonw jaasonw left a comment

Choose a reason for hiding this comment

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

i did not look at it so therefore i see no issues with it

Copy link
Contributor

@charliettaylor charliettaylor left a comment

Choose a reason for hiding this comment

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

image

@vercel vercel bot temporarily deployed to Preview October 14, 2022 07:51 Inactive
@EthanThatOneKid EthanThatOneKid enabled auto-merge (squash) October 14, 2022 07:53
@EthanThatOneKid EthanThatOneKid merged commit 8d7324b into main Oct 14, 2022
@jaasonw jaasonw deleted the fix/557 branch December 27, 2022 12:39
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.

Save screenshots as side-effect in Playwright tests
5 participants