In this article, we review some Playwright code snippets in Meshery codebase. We will look at:
What is Playwright?
Playwright configuration in Meshery.
I study patterns used in an open source project found on Github Trending. For this week, I reviewed some parts of Meshery codebase and wrote this article.
Test Mobile Web. Native mobile emulation of Google Chrome for Android and Mobile Safari. The same rendering engine works on your Desktop and in the Cloud.
Auto-wait. Playwright waits for elements to be actionable prior to performing actions. It also has a rich set of introspection events. The combination of the two eliminates the need for artificial timeouts — the primary cause of flaky tests.
Web-first assertions. Playwright assertions are created specifically for the dynamic web. Checks are automatically retried until the necessary conditions are met.
Tracing. Configure test retry strategy, capture execution trace, videos, screenshots to eliminate flakes.
Tests folder name (default: tests, or e2e if tests already exists)
Add a GitHub Actions workflow (recommended for CI)
Install Playwright browsers (default: yes)
You can re-run the command later; it does not overwrite existing tests.
When you run this command, the following files are created:
playwright.config.ts # Test configurationpackage.jsonpackage-lock.json # Or yarn.lock / pnpm-lock.yamltests/ example.spec.ts # Minimal example testtests-examples/ demo-todo-app.spec.ts # Richer example tests
tests/ contains a minimal starter test. tests-examples/ provides richer samples (e.g. a todo app) to explore patterns.