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

Playwright Migration and GitHub Actions for CI #7

Merged
merged 7 commits into from
Aug 25, 2024
Merged

Conversation

JRJurman
Copy link
Member

@JRJurman JRJurman commented Aug 25, 2024

Summary

Previously, we were using Cypress for out Automated testing, however it was not possible to trivially run that in CI, and the ergonomics of the automation test were honestly not that great.

This PR migrates the tests to Playwright, which allows for a more straight-forward interface when writing tests and interfacing with Web Components.

Checklist

  • PR Summary
  • PR Annotations
  • Tests
  • Version Bump (not required, no source changes)

@@ -0,0 +1,25 @@
name: Tram-Deco Playwright Tests
Copy link
Member Author

Choose a reason for hiding this comment

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

This file is almost entirely from the npx playwright install, and is probably the most bare-bones we could probably get this to be.

Comment on lines +5 to +7
const getTextContent = async (element) => {
return await element.evaluate((el) => el.textContent);
};
Copy link
Member Author

Choose a reason for hiding this comment

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

the default toHaveText does not work as expected with slots that have default content. There is probably an issue to raise in the playwright repository, but for the moment, just using this custom function to evaluate the results of textContent manually.

return await element.evaluate((el) => el.textContent);
};

test.describe('Tram-Deco Example Components', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

this is pretty much a translation of spec.cy.js - I used ChatGPT to migrate one to the other

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
Copy link
Member Author

Choose a reason for hiding this comment

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

We've left this template pretty much untouched, but may update in the future. For now, this is fine.

@JRJurman JRJurman merged commit 1bd597e into main Aug 25, 2024
1 check passed
@JRJurman JRJurman deleted the playwright branch January 19, 2025 19:57
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.

1 participant