<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Charmi Vyas on Medium]]></title>
        <description><![CDATA[Stories by Charmi Vyas on Medium]]></description>
        <link>https://medium.com/@12charmi?source=rss-64acd8e87e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VmIRUyXDgKTFmSZW.jpg</url>
            <title>Stories by Charmi Vyas on Medium</title>
            <link>https://medium.com/@12charmi?source=rss-64acd8e87e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 07:33:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@12charmi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automating Releases with Release Please: A Practical Guide]]></title>
            <link>https://medium.com/@12charmi/automating-releases-with-release-please-a-practical-guide-for-developers-52522dde1ae5?source=rss-64acd8e87e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/52522dde1ae5</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[production]]></category>
            <category><![CDATA[version-management]]></category>
            <category><![CDATA[changelog-generation]]></category>
            <category><![CDATA[release-please]]></category>
            <dc:creator><![CDATA[Charmi Vyas]]></dc:creator>
            <pubDate>Mon, 09 Nov 2026 12:35:34 GMT</pubDate>
            <atom:updated>2026-11-10T12:43:06.437Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d7WLS4vU6KHstqoL" /><figcaption>Photo by <a href="https://unsplash.com/@coopery?utm_source=medium&amp;utm_medium=referral">Mohamed Nohassi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Standardising commit history, automating versioning, and simplifying GitHub releases.</em></p><p>Software releases involve more than writing and merging code. Developers also need to manage version numbers, maintain changelogs, create Git tags, and publish release notes.</p><p>As a project grows, handling these tasks manually can lead to inconsistent release processes and unnecessary maintenance.</p><p><strong>Release Please</strong> addresses this by automating release preparation while keeping the team in control of when a release is finalised.</p><p>This article covers why we need Release Please, how it works, its engineering benefits, and practical considerations when integrating it into a Next.js repository.</p><h3>1. Why do we need Release Please?</h3><p>Without a standardised release process, teams often face:</p><ul><li>Inconsistent commit message formats.</li><li>Manual and unpredictable version updates.</li><li>Changelogs that are difficult to maintain.</li><li>Missing or inconsistent Git tags and GitHub Releases.</li><li>Difficulty tracking changes between releases.</li></ul><p>The objective is to establish a consistent process for:</p><ul><li>Standardising commit conventions.</li><li>Following Semantic Versioning (SemVer).</li><li>Automating changelog generation.</li><li>Maintaining traceable release history.</li><li>Simplifying GitHub release management.</li></ul><h3>2. What is Release Please?</h3><p><a href="https://github.com/googleapis/release-please">Release Please</a>, developed by Google, is an open-source release automation tool.</p><p>It analyses Conventional Commits and automates:</p><ul><li>Version calculation.</li><li>Changelog generation.</li><li>Release Pull Request creation.</li><li>Git tagging.</li><li>GitHub Release creation.</li></ul><p>Instead of manually preparing every release, Release Please creates a reviewable Pull Request with the proposed release changes.</p><p><strong>The key idea:</strong> Automate release preparation while keeping developers in control through Pull Request reviews.</p><h3>3. Understanding Semantic Versioning (SemVer)</h3><p>Release Please follows Semantic Versioning to determine the next release version.</p><p>The version format is:</p><p>MAJOR.MINOR.PATCH</p><p>VersionPurposeExampleMAJORBreaking changes1.0.0MINORNew features0.2.0PATCHBug fixes0.0.2</p><p>Conventional Commit messages help determine the version increment:</p><p>Commit typeRelease impactfix:PATCHfeat:MINORBREAKING CHANGE: or breaking-change indicator (!)MAJORchore:Usually no release</p><p>This makes versioning more predictable and reduces manual decisions.</p><h3>4. Why are Git tags important?</h3><p>Every release creates a Git tag associated with a specific commit.</p><p>A Git tag acts as a permanent reference point for a released version.</p><p>For example:</p><p>v0.0.1 → v0.0.2 → v0.1.0 → v1.0.0</p><p>Each tag helps developers:</p><ul><li><strong>Trace changes:</strong> Identify the exact code associated with a release.</li><li><strong>Compare versions:</strong> Review differences between releases.</li><li><strong>Debug issues:</strong> Identify which changes were introduced.</li><li><strong>Rollback:</strong> Locate a previously released code snapshot.</li><li><strong>Maintain history:</strong> Keep a consistent record of releases.</li></ul><p>This makes release history easier to understand and maintain.</p><h3>5. Why Release Please?</h3><p>Instead of building and maintaining our own release automation, Release Please provides an established, open-source solution.</p><p>Key advantages:</p><ul><li><strong>Open-source:</strong> Developed by Google and available under the Apache 2.0 licence.</li><li><strong>Established:</strong> A widely adopted release automation tool.</li><li><strong>Framework-agnostic:</strong> Works with Git history and GitHub Actions rather than depending on a specific application framework.</li><li><strong>Multi-ecosystem support:</strong> Supports different languages and project types.</li><li><strong>Configurable:</strong> Supports custom release strategies, changelog sections, and version management.</li></ul><p>This makes it suitable for standardising release processes across frontend, backend, and other repositories.</p><h3>6. How does the release workflow work?</h3><p>Release Please introduces a predictable and reviewable release lifecycle.</p><p><strong>Step 1: Developers merge changes</strong></p><p>Developers follow Conventional Commit formats such as feat:, fix:, and chore:.</p><p><strong>Step 2: GitHub Actions triggers Release Please</strong></p><p>Release Please analyses commits since the previous release and determines whether a release is required.</p><p><strong>Step 3: Release Pull Request is created</strong></p><p>It prepares the proposed version update, CHANGELOG.md, and relevant package metadata changes.</p><p><strong>Step 4: Review and merge</strong></p><p>The team reviews the proposed version and changelog before approving the release.</p><p><strong>Step 5: GitHub Release is generated</strong></p><p>After the Release PR is merged, Release Please creates the Git tag and corresponding GitHub Release.</p><p><strong>Two important distinctions:</strong></p><ul><li>Automated: Version calculation, changelog updates, Git tagging, and GitHub Release creation.</li><li>Team-controlled: The release is finalised only after the Release PR is reviewed and merged.</li></ul><p>Release Please does not automatically deploy the application or publish packages to npm. These remain separate CI/CD responsibilities.</p><h3>7. Implementation in a Next.js repository</h3><p>For a single-package Next.js application using npm, the basic integration requires:</p><ol><li>GitHub Actions enabled in the repository.</li><li>Conventional Commit messages.</li><li>Appropriate GitHub Actions permissions.</li><li>Release Please configured with the node release strategy.</li></ol><h3>GitHub Actions workflow</h3><p>Create .github/workflows/release-please.yml:</p><pre>name: Release Please</pre><pre>on:<br>  workflow_dispatch:<br>  push:<br>    branches:<br>      - dev</pre><pre>permissions:<br>  contents: write<br>  pull-requests: write</pre><pre>jobs:<br>  release:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Release Please<br>        uses: googleapis/release-please-action@v4<br>        with:<br>          token: ${{ secrets.GITHUB_TOKEN }}<br>          release-type: node</pre><p><em>Note: Replace </em><em>dev with the repository&#39;s configured release target branch.</em></p><p>For a basic single-package Node.js or Next.js project, the release-type: node input is sufficient.</p><p>Additional configuration files are optional:</p><ul><li>release-please-config.json: Custom release configuration and changelog settings.</li><li>.release-please-manifest.json: Tracks the last released version for manifest-based release management.</li></ul><p>Start with the simplest configuration that meets the repository’s requirements.</p><h3>Enforcing Conventional Commits</h3><p>Release Please depends on commit messages to determine release changes.</p><p>To maintain consistency, Conventional Commit validation can be introduced through commit hooks or pre-commit checks.</p><p>This helps ensure that the commit history remains meaningful and release information is captured correctly.</p><h3>8. Practical considerations and lessons learned</h3><p>Some important considerations when setting up Release Please:</p><p>ScenarioConsiderationInitial releaseUse release-as to specify the first release version, such as 0.0.1. Remove the override afterwards.Git tag prefixThe v prefix is optional. Choose one convention and maintain it consistently.Existing Release PRNew commits can update the existing Release PR rather than creating another one.Package versionThe Node release strategy updates package.json in the Release PR. Review related lockfile changes.npm publishingRequires a separate publishing workflow and npm authentication.Deleted GitHub releaseDeleting a release or tag does not automatically reset Release Please&#39;s release history.Release resetAlign existing tags, release history, and manifest versions before restarting the release baseline.</p><h3>A few additional points</h3><p><strong>Initial version</strong></p><p>To start with 0.0.1, configure:</p><pre>release-as: 0.0.1</pre><p>This overrides the calculated version but does not disable commit analysis. Remove it after the initial release.</p><p><strong>Release PR lifecycle</strong></p><p>Release Please maintains an existing release PR. When additional commits reach the target branch, it can update the same PR with the latest release information.</p><p><strong>GitHub Actions permissions</strong></p><p>The workflow requires:</p><pre>permissions:<br>  contents: write<br>  pull-requests: write</pre><p>Also ensure that GitHub Actions is allowed to create Pull Requests in the repository settings.</p><p><strong>Release management vs deployment</strong></p><p>Release Please handles release preparation and GitHub Releases. Application deployment and npm publishing can be triggered independently through other workflows.</p><h3>Conclusion</h3><p>Release Please is not just about automating version numbers. It establishes a consistent, predictable, and traceable release management process.</p><p>With this integration, we achieve:</p><ul><li>Standardised commit conventions.</li><li>Automated Semantic Versioning.</li><li>Consistently maintained changelogs.</li><li>Reviewable release approvals.</li><li>Git tags as permanent release references.</li><li>Simplified GitHub release management.</li><li>A reusable approach across repositories and technology stacks.</li></ul><p><strong>The takeaway:</strong></p><p><em>Standardise how we commit, automate how we version, document what we release, and maintain a reliable history of every release.</em></p><h3>References</h3><ul><li><a href="https://github.com/googleapis/release-please">Release Please — Core Documentation</a></li><li><a href="https://github.com/googleapis/release-please-action">Release Please — GitHub Action</a></li><li><a href="https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md">Manifest Configuration</a></li><li><a href="https://www.conventionalcommits.org/en/v1.0.0/">Conventional Commits</a></li><li><a href="https://semver.org/">Semantic Versioning</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52522dde1ae5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ Protecting Your Routes in Playwright: Smart Way to Handle Authenticated Pages #TestingDay3]]></title>
            <link>https://medium.com/@12charmi/%EF%B8%8F-protecting-your-routes-in-playwright-smart-way-to-handle-authenticated-pages-testingday3-109bf5d2b5ac?source=rss-64acd8e87e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/109bf5d2b5ac</guid>
            <category><![CDATA[frontend-testing]]></category>
            <category><![CDATA[learn-by-doing]]></category>
            <category><![CDATA[code-in-typescript]]></category>
            <category><![CDATA[playwright-automation]]></category>
            <category><![CDATA[end-to-end-testing]]></category>
            <dc:creator><![CDATA[Charmi Vyas]]></dc:creator>
            <pubDate>Fri, 18 Jul 2025 04:32:08 GMT</pubDate>
            <atom:updated>2025-07-18T04:32:08.095Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey everyone! 👋</p><p>When working on automated tests for modern apps, <strong>authentication</strong> can be a bottleneck. Logging in for every test? Slow and repetitive.<br>My goal was simple:</p><blockquote><strong><em>“Login once, store the session, and reuse it across tests.”</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AuEgf0LwTjMFcwranc5g5w.png" /></figure><p>There are pre-defined ways to handle the <a href="https://playwright.dev/docs/auth#introduction"><strong>authentication</strong></a><strong> </strong>in playwright</p><p>In this article, I’ll walk you through <strong>how I handled authentication testing in Playwright</strong> efficiently using stored sessions, a global setup, and a clean custom test() export.</p><h3>🔐 Why Auth Route Testing Matters</h3><p>Authenticated routes — like dashboards or user profiles — should only be accessible <strong>after login</strong>.<br> So our test cases need to:</p><ul><li>Redirect unauthenticated users to login</li><li>Allow access to protected pages <strong>only</strong> after login</li><li>Handle session state effectively across multiple test files</li></ul><h3>🧰 Playwright Concepts Used</h3><p>To make this work, I used some core Playwright features:</p><h3>1. test.extend() – Creating a Custom Test Setup</h3><p>We created a <strong>custom test instance</strong> that comes with storageState built in. That way, we don’t need to write test.use(...) in every file.</p><pre>// custom test file<br>import { test as base } from &#39;@playwright/test&#39;;<br><br>// defining the usage of default user session by extending test function<br>export const test = base.extend({<br>    storageState: &#39;playwright/.auth/user.json&#39;<br>});});</pre><blockquote><em>This gives you a reusable </em><em>test() that already knows the user is logged in.</em></blockquote><h3>2. global-setup.ts – Logging in Once, Reusing Many</h3><p>We create a global-setup.ts file to <strong>log in once before all tests</strong>, store the session, and save it into .auth/user.json.</p><pre>// global-setup.ts<br><br>import { expect } from &#39;@playwright/test&#39;;<br>import path from &#39;path&#39;;<br>import fs from &#39;fs&#39;;<br>import { chromium } from &#39;@playwright/test&#39;;<br><br>const authFile = path.join(__dirname, &#39;../.auth/user.json&#39;);<br>const APP_URL = String(process.env.NEXT_PUBLIC_SITE_URL);<br><br>async function globalSetup() {<br>    const browser = await chromium.launch();<br>    const page = await browser.newPage();<br><br>    await page.goto(APP_URL);<br>    await page.getByRole(&#39;textbox&#39;, { name: &#39;username&#39; }).fill(&quot;username&quot;)<br>    await page.getByRole(&#39;textbox&#39;, { name: &#39;password&#39; }).fill(&quot;password&quot;)<br>    await page.locator(&#39;button[type=submit]&#39;).click();<br><br>    // Wait until the page user session is stored in the cookies.<br>    await expect(page).toHaveURL(/\/dashboard/);<br><br>    // End of authentication steps.<br>    await page.context().storageState({ path: authFile });<br><br>    await browser.close();<br>}<br><br>export default globalSetup;</pre><p>Then, update the playwright.config.ts:</p><pre>export default defineConfig({<br>  globalSetup: &quot;./playwright/tests/global-setup.ts&quot;,<br>});</pre><h3>3. describe() Block – Resetting Behavior When Needed</h3><p>Sometimes you may want to <strong>reset or override</strong> the authentication behavior inside a group of tests. You can do that with test.describe() and explicitly override options.</p><pre>test.describe(&#39;Unauthenticated flows&#39;, () =&gt; {<br>  test.use({ storageState: undefined });<br>  test(&#39;should redirect to login page&#39;, async ({ page }) =&gt; {<br>    await page.goto(&#39;/dashboard&#39;);<br>    await expect(page).toHaveURL(&#39;/login&#39;);<br>  });<br>});</pre><blockquote><em>This overrides the default storage state </em><strong><em>just for this block</em></strong><em> — letting you test logged-out flows too.</em></blockquote><h3>✅ Important Note: Always Import From Your Custom Test</h3><p>To make sure your session state is applied automatically, remember to <strong>import the test object from your custom file</strong>.</p><pre>// dashboard.spec.ts<br>import { expect } from &#39;@playwright/test&#39;; <br>import { test } from &#39;../utils/testWithPermission&#39;;// not from &#39;@playwright/test&#39;</pre><blockquote><em>If you import from </em><em>@playwright/test directly, you’ll lose the pre-configured storage state and need to manually define it again.</em></blockquote><h3>🚀 Final Thoughts</h3><p>By combining:</p><ul><li>globalSetup to store session once</li><li>test.extend to reuse across files</li><li>Smart usage of describe() blocks</li></ul><p>… you can <strong>dramatically speed up your test suite</strong> and keep your test logic clean.</p><p>💡 This setup is especially helpful as your test suite grows. You don’t want login code in every test — just <strong>write once, reuse everywhere</strong>.</p><p>📌 Let me know in the comments — how do you handle auth in your tests?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=109bf5d2b5ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Login Flows with Playwright: From Form Fill to Redirect #TestingDay2]]></title>
            <link>https://medium.com/@12charmi/testing-login-flows-with-playwright-from-form-fill-to-redirect-testingday2-dc7ebb826928?source=rss-64acd8e87e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc7ebb826928</guid>
            <category><![CDATA[end-to-end-testing]]></category>
            <category><![CDATA[code-in-typescript]]></category>
            <category><![CDATA[playwright-automation]]></category>
            <category><![CDATA[frontend-testing]]></category>
            <category><![CDATA[learn-by-doing]]></category>
            <dc:creator><![CDATA[Charmi Vyas]]></dc:creator>
            <pubDate>Thu, 17 Jul 2025 04:32:23 GMT</pubDate>
            <atom:updated>2025-07-17T04:32:23.559Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey everyone! 👋</p><p>Continuing my writing streak on building a Playwright testing POC — this time, we’re diving into a very common and essential part of any app: the <strong>login flow</strong>.</p><p>In this post, I’ll walk you through how to test a login page properly, step by step. Along the way, I’ll also share a small issue I faced with environment variables (and how I fixed it) — because let’s be real, testing isn’t always smooth, especially when you’re just getting started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ahxuEQgQTpLijOjGFCJ6g.png" /></figure><h3>🎯 Why Test the Login Flow?</h3><p>Login is the <strong>first real user interaction</strong> in most apps. If that breaks — users get stuck. So it’s one of the first places you want automated test coverage.</p><p>And while testing can feel technical, a good habit is to write tests like you’re <strong>mimicking how a real user behaves</strong> — this is part of a practice called <strong>BDD</strong> (Behavior Driven Development).</p><h3>✅ What Should We Validate in a Login Flow?</h3><p>Here’s the list of what I wanted my test to cover:</p><ol><li><strong>Verify we’re on the correct login route</strong> (/login)</li><li><strong>Check the page title and if the form is visible</strong></li><li><strong>Make sure the submit button is rendered</strong></li><li><strong>Trigger and validate error messages on empty fields</strong></li><li><strong>Enter invalid credentials and check for proper feedback</strong></li><li><strong>Enter valid credentials and check for success</strong></li><li><strong>Verify redirection to the dashboard page (check URL and title)</strong></li></ol><p>Simple, real, and effective. If these pass, I know the core auth flow is working as expected.</p><h3>🧪 Writing the Test</h3><p>I created a new file for this: login.spec.ts</p><p>Each step was added in the order listed above, and I made sure the test looked like how a user would actually use the form — click, type, submit, and check what happens.</p><p>Link to my test file : <a href="https://github.com/18charmi/admin-dashboard/blob/main/tests/login.spec.ts">https://github.com/18charmi/admin-dashboard/blob/main/tests/login.spec.ts</a></p><pre>import { test, expect } from &#39;@playwright/test&#39;;<br>const APP_URL = String(process.env.NEXT_PUBLIC_SITE_URL);<br>test(&#39;Check for the login route&#39;, async ({ page }) =&gt; {<br>    await page.goto(APP_URL);<br>    await expect(page).toHaveURL(/\/login/);<br>});<br><br>test(&#39;Validate the page elements : title, form to be visible, submit button&#39;, async ({ page }) =&gt; {<br>    await page.goto(APP_URL);<br>    await expect(page.getByRole(&#39;heading&#39;)).toHaveText(&quot;Welcome Back&quot;)<br><br>    await page.getByRole(&#39;form&#39;).isVisible();<br>    await expect(page.getByRole(&#39;textbox&#39;, { name: &#39;username&#39; })).toBeVisible();<br>    await expect(page.getByRole(&#39;textbox&#39;, { name: &#39;password&#39; })).toBeVisible();<br>    await expect(page.locator(&#39;button[type=submit]&#39;)).toBeVisible();<br>    await expect(page.locator(&#39;button[type=submit]&#39;)).toHaveText(&quot;Login&quot;);<br>});<br>test(&#39;Validate the possible error message of forms&#39;, async ({ page }) =&gt; {<br>    await page.goto(APP_URL);<br>    await expect(page.getByRole(&#39;heading&#39;)).toHaveText(&quot;Welcome Back&quot;)<br><br>    await expect(page.locator(&#39;button[type=submit]&#39;)).toBeEnabled();<br>    await page.locator(&#39;button[type=submit]&#39;).click();<br>    await expect(page.getByTestId(&#39;username-container&#39;)).toContainText(&quot;Username is required&quot;);<br>    await expect(page.getByTestId(&#39;password-container&#39;)).toContainText(&quot;Password is required&quot;);<br><br>    await page.getByRole(&#39;textbox&#39;, { name: &#39;username&#39; }).fill(&quot;emilys&quot;)<br>    await page.getByRole(&#39;textbox&#39;, { name: &#39;password&#39; }).fill(&quot;emilyspass&quot;)<br>    await expect(page.getByTestId(&#39;username-container&#39;)).not.toContainText(&quot;Username is required&quot;);<br>    await expect(page.getByTestId(&#39;password-container&#39;)).not.toContainText(&quot;Password is required&quot;);<br>});<br><br>test(&#39;Getting user feedback messages on invalid credentials&#39;, async ({ page }) =&gt; {<br>    await page.goto(APP_URL);<br><br>    await page.getByRole(&#39;textbox&#39;, { name: &#39;username&#39; }).fill(&quot;emilys&quot;)<br>    await page.getByRole(&#39;textbox&#39;, { name: &#39;password&#39; }).fill(&quot;emilypass&quot;)<br>    await page.locator(&#39;button[type=submit]&#39;).click();<br>    await page.getByTestId(&#39;alert-container&#39;).isVisible();<br>    await expect(page.getByTestId(&#39;alert-container&#39;)).toHaveText(&#39;Invalid credentials&#39;);<br>    await expect(page.getByTestId(&#39;alert-container&#39;)).not.toBeVisible()<br>});<br><br>test(&#39;Login Success Action&#39;, async ({ page }) =&gt; {<br>    await page.goto(APP_URL);<br><br>    await page.getByRole(&#39;textbox&#39;, { name: &#39;username&#39; }).fill(&quot;emilys&quot;)<br>    await page.getByRole(&#39;textbox&#39;, { name: &#39;password&#39; }).fill(&quot;emilyspass&quot;)<br>    await page.locator(&#39;button[type=submit]&#39;).click();<br>    await page.getByTestId(&#39;alert-container&#39;).isVisible();<br>    await expect(page.getByTestId(&#39;alert-container&#39;)).toHaveText(&#39;Login Success&#39;);<br>    await expect(page).toHaveURL(/\/dashboard/);<br>    await expect(page.locator(&quot;header&quot;)).toContainText(&quot;Welcome Admin&quot;)<br>    await expect(page.locator(&quot;header button&quot;)).toContainText(&quot;Log Out&quot;)<br>});</pre><h3>⚠️ The Problem I Faced: Environment Variables in Playwright</h3><p>Since my app is built with <strong>Next.js</strong>, I already had environment variables like BASE_URL defined in a .env.local file.</p><p>But when running Playwright tests, I noticed:<br> <strong>process.env.BASE_URL was undefined in my test files</strong> 😅</p><p>Turns out: <strong>Playwright doesn’t load </strong><strong>.env files by default</strong>.</p><h3>✅ The Fix: Load .env Using dotenv</h3><p>Here’s what I did:</p><ol><li>Installed the dotenv package:</li></ol><p>npm install dotenv</p><ol><li>Updated the playwright.config.ts to load the .env file:</li></ol><pre>import dotenv from &#39;dotenv&#39;; <br>import path from &#39;path&#39;;  <br><br>dotenv.config({ path: path.resolve(__dirname, &#39;.env&#39;) });</pre><p>The solution was already present in the config file but commented out by default after running the Playwright init step.</p><p>Boom! My process.env.NEXT_PUBLIC_APP_URL was now available in tests.</p><h3>🧭 What’s Next?</h3><p>In the upcoming articles, I’ll continue building on this by testing protected routes, logout flows, and more UI interactions.</p><p>The key takeaway? <strong>Testing should feel like a user walking through your app</strong>, not just code verifying code.</p><p>If you’re starting with Playwright, I hope this helps you avoid a few bumps and gives you a practical way to think about testing your login flow.</p><p>Thanks for reading! 🙌<br> Feel free to drop questions or feedback — and if you’re testing something cool, I’d love to hear how you’re approaching it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc7ebb826928" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Playwright: Your First E2E Test in Minutes #TestingDay1]]></title>
            <link>https://medium.com/@12charmi/getting-started-with-playwright-your-first-e2e-test-in-minutes-testingday1-fa8855b3f5cb?source=rss-64acd8e87e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa8855b3f5cb</guid>
            <category><![CDATA[code-in-typescript]]></category>
            <category><![CDATA[playwright-automation]]></category>
            <category><![CDATA[end-to-end-testing]]></category>
            <category><![CDATA[learn-by-doing]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Charmi Vyas]]></dc:creator>
            <pubDate>Wed, 16 Jul 2025 12:45:40 GMT</pubDate>
            <atom:updated>2025-07-16T12:45:40.921Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi everyone 👋</p><p>I’m starting a small writing streak to document and build a working POC (proof of concept) for <strong>automation testing</strong> using <a href="https://playwright.dev/">Playwright</a>.<br> The goal is to walk through common testing scenarios step by step, keeping things as simple and real-world as possible.</p><p>So if you’re just getting into testing or looking for a tool to automate user flows in your app — you’re in the right place.</p><p>Let’s start with the basics: <strong>setting up Playwright</strong> and running your <strong>first test</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t1Otic2RQNMUkIg5IhLSnQ.png" /></figure><h3>🛠 Step 1: Go to Your Project</h3><p>Open your terminal and move into the root folder of the app you want to test.</p><p>If you don’t have a project yet, feel free to spin up a basic React, Next.js, or plain HTML app — anything that runs locally or production ready site will work.</p><h3>📦 Step 2: Install Playwright</h3><p>In the terminal, run this command:</p><pre>npm init playwright</pre><p>This command does a few things:</p><ul><li>Installs Playwright and its core dependencies</li><li>Downloads browser binaries (like Chromium, Firefox, WebKit)</li><li>Creates a basic testing setup for you</li></ul><p>👉 You can refer to the <a href="https://playwright.dev/docs/intro">official Playwright installation guide here</a> if needed.</p><h3>🤖 Step 3: Answer the Prompts</h3><p>After running the command, Playwright will ask you a few setup questions.</p><p>If you’re unsure, just <strong>go with the default options</strong> — that works for most projects.</p><h3>📁 Step 4: Explore the Setup</h3><p>Once it’s done, you’ll see:</p><ul><li>A playwright.config.ts file (your test config, based on selected default prompts)</li><li>A tests/ folder with a sample test file (folder name is defined while running the init)</li><li>Scripts shown to run tests in multiple manner — ensure to add in your package.json script</li></ul><p>This gives you a ready-to-go setup to start writing your own test cases.</p><h3>🚀 Step 5: Run Your First Test</h3><p>To run tests in <strong>headless mode</strong> (no browser UI):</p><pre>npx playwright test</pre><p>To run in <strong>UI mode</strong> (great for debugging):</p><pre>npx playwright test --ui</pre><p>That’s it! 🎉 You’ve officially run your first test using Playwright.</p><h3>🧭 What’s Next?</h3><p>In the next part of this series, we’ll write a test for a <strong>real-world login flow</strong>, handle <strong>form validation</strong>, and work with <strong>protected routes</strong> — the kinds of things every app needs.</p><p>Thanks for reading! If you’re just starting out, don’t stress — Playwright makes testing pretty approachable. Feel free to follow along, drop feedback, or share what you’re building.</p><p>Happy testing! 🧪✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa8855b3f5cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Clean Code with Prettier, Pretty-Quick to sort the imports in Next.js]]></title>
            <link>https://medium.com/@12charmi/clean-code-with-prettier-pretty-quick-to-sort-the-imports-in-next-js-27357b903d1d?source=rss-64acd8e87e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/27357b903d1d</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[pretty-quick]]></category>
            <category><![CDATA[prettier]]></category>
            <category><![CDATA[husky]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Charmi Vyas]]></dc:creator>
            <pubDate>Thu, 26 Jun 2025 14:03:02 GMT</pubDate>
            <atom:updated>2025-06-26T14:03:02.414Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VN5GspGszdHkaj1d" /><figcaption>Photo by <a href="https://unsplash.com/@bradyn?utm_source=medium&amp;utm_medium=referral">Bradyn Trollip</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In one of my recent Next.js projects, I streamlined my pre-commit workflow using <strong>husky</strong>, <strong>pretty-quick</strong>, and p<strong>rettier</strong>. The goal was simple: keep every commit clean and consistent — and now, also beautifully sorted.</p><p>If you’re new to Husky, check out <a href="https://medium.com/@12charmi/dev-tip-use-husky-to-auto-check-code-before-you-commit-90804f6d473a">this practical guide</a> on setting up Husky before jumping in.</p><h3>✨ Automating Code Formatting</h3><p>I use <strong>pretty-quick</strong> to run Prettier only on staged files. It integrates seamlessly with Git via a pre-commit hook.</p><p>Within the separate .husky/pre-commit file, I to run the pre-commit script defined in the package.json:</p><pre>&quot;scripts&quot;: {<br>  &quot;precommit&quot;: &quot;pretty-quick --staged&quot;<br>}</pre><p>With this in place, every time I commit code, Prettier automatically formats the staged files — no extra effort needed.</p><h3>📦 Sorted Imports with Trivago Plugin</h3><p>To keep import statements organized, I added <a href="https://github.com/trivago/prettier-plugin-sort-imports"><strong>@trivago/prettier-plugin-sort-imports</strong></a>. It works alongside Prettier and automatically arranges imports based on a defined order.</p><p>Here’s my .prettierrc config:</p><pre>{<br>  &quot;plugins&quot;: [&quot;@trivago/prettier-plugin-sort-imports&quot;],<br>  &quot;importOrder&quot;: [&quot;&lt;THIRD_PARTY_MODULES&gt;&quot;, &quot;@/(.*)$&quot;, &quot;^[./]&quot;],<br>  &quot;importOrderSeparation&quot;: true,<br>  &quot;importOrderSortSpecifiers&quot;: true<br>}</pre><p>Now, both formatting and import sorting happen together — automatically.</p><h3>🧪 One-Click Formatting</h3><p>Need to clean up your whole codebase?</p><pre>&quot;scripts&quot;: {<br>  &quot;format&quot;: &quot;prettier --write &#39;./src/**/*.{ts,tsx,js,jsx}&#39;&quot;<br>}</pre><p>This is great for quick codebase-wide consistency before a big push.</p><blockquote><em>Why don’t developers clean their code manually before committing?<br> Because they believe in </em>commitment<em>, not </em>chores<em>. 😄</em></blockquote><h3>✅ Final Thoughts</h3><p>With this setup:</p><ul><li><strong>Prettier</strong> handles formatting</li><li><a href="https://prettier.io/docs/precommit#option-2-pretty-quick"><strong>Pretty-Quick</strong> </a>formats only staged files</li><li><a href="https://github.com/trivago/prettier-plugin-sort-imports"><strong>Trivago’s plugin</strong></a> keeps your imports tidy</li></ul><p>It’s a lightweight combo that makes a big difference in code quality and consistency.</p><p><strong>Happy coding — and may your imports always be in order!</strong> ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27357b903d1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Dev Tip: Use Husky to Auto-Check Code Before You Commit]]></title>
            <link>https://medium.com/@12charmi/dev-tip-use-husky-to-auto-check-code-before-you-commit-90804f6d473a?source=rss-64acd8e87e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/90804f6d473a</guid>
            <category><![CDATA[code-linting]]></category>
            <category><![CDATA[code-review-tool]]></category>
            <category><![CDATA[husky]]></category>
            <category><![CDATA[pre-commit]]></category>
            <dc:creator><![CDATA[Charmi Vyas]]></dc:creator>
            <pubDate>Fri, 30 May 2025 07:06:56 GMT</pubDate>
            <atom:updated>2025-05-30T07:06:56.045Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever committed code and <em>then</em> remembered you forgot to run the linter? Or pushed broken code that failed tests?<br> Yeah… me too. 😅</p><p>That’s why I started using <a href="https://typicode.github.io/husky/"><strong>Husky</strong></a> — a small package that runs scripts <em>before</em> your code gets committed.</p><h3>🚀 What Husky Does</h3><p>Husky helps you:</p><ul><li>Run checks (like lint, test, or prettier) <strong>before github workflows like committing, push, lint-staging, and so..</strong></li><li>Keep your code clean</li><li>Save yourself from pushing bugs or style issues</li></ul><p>Basically: it’s your friendly Git bodyguard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LmskN6BQCXM2F5Pw" /><figcaption>Photo by <a href="https://unsplash.com/@brunocervera?utm_source=medium&amp;utm_medium=referral">BRUNO CERVERA</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>🛠️ Quick Setup</h3><ol><li><strong>Install it</strong></li></ol><pre>npm install husky --save-dev</pre><p><strong>2. Initialize husky setup</strong></p><pre>npx husky init</pre><p><strong>3. Check the visible updates</strong></p><p>In yourpackage.json, you’ll now see a prepare script</p><pre>&quot;scripts&quot;: {<br>  &quot;prepare&quot;: &quot;husky&quot;<br>}</pre><p>So when you run</p><pre>npm install</pre><p>…it installs the project dependencies &amp; automatically runs the <a href="https://docs.npmjs.com/cli/v8/using-npm/scripts#:~:text=Runs%20on%20local%20npm%20install%20without%20any%20arguments">prepare scripts</a></p><p>This is helpful for projects using devDependencies to build assets or manage pre-commit tasks.</p><p><strong>4. A new file appears: </strong><strong>.husky/pre-commit</strong></p><p>This file is where you define what happens <strong>before a commit</strong>. You can customize it based on your project needs —</p><pre>npm run lint</pre><p>Now every time you commit, it’ll auto-run npm run lint. <br>If there’s a problem, it blocks the commit.</p><h3>💡 Try It Out</h3><p>Make a messy code change, then:</p><pre>git add .<br>git commit -m &quot;testing husky&quot;</pre><p>Watch Husky catch it before the commit goes through!</p><p>🎥Watch it working in real-time : <a href="https://youtu.be/AciX5EM62-c">https://youtu.be/AciX5EM62-c</a></p><h3>✅ Done!</h3><p>That’s it — Husky is now guarding your commits like a pro.<br> No more forgetting lint, tests, or formatting. 🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90804f6d473a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Custom Searchable Autocomplete in React with TypeScript — Lightweight, Reusable & Clean]]></title>
            <link>https://medium.com/@12charmi/building-a-custom-searchable-autocomplete-in-react-with-typescript-lightweight-reusable-clean-817845f3f89c?source=rss-64acd8e87e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/817845f3f89c</guid>
            <category><![CDATA[autocomplete-component]]></category>
            <category><![CDATA[react-select]]></category>
            <category><![CDATA[react-typescript]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[reactdev]]></category>
            <dc:creator><![CDATA[Charmi Vyas]]></dc:creator>
            <pubDate>Thu, 22 May 2025 18:47:35 GMT</pubDate>
            <atom:updated>2025-05-22T18:47:35.381Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Custom Searchable Autocomplete in React with TypeScript — Lightweight, Reusable &amp; Clean</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYrGQYc6GKLn0txLkEIYRg.png" /></figure><p>Autocomplete inputs are everywhere 🔍 - from search bars to dropdown filters — making it easier for users to find what they want fast. But building one that’s flexible, lightweight, and easy to maintain isn’t always straightforward.</p><p>I recently created a <strong>custom searchable autocomplete component</strong> in <strong>React</strong> using <strong>TypeScript</strong>, <strong>react-select</strong>, <strong>TailwindCSS</strong>, and <strong>Vite</strong>. I wanted a component that:</p><ul><li>Doesn’t pull in a huge UI package just for one feature</li><li>Keeps async fetching logic clean and reusable</li><li>Is fully customizable and supports keyboard accessibility</li><li>Leverages the solid base and active maintenance of the popular react-select library</li></ul><h3>Why build a custom autocomplete?</h3><p>You might ask, “Why not just use a pre-built autocomplete from a UI library?”</p><p>Well, importing a full UI framework for a single input felt like using a sledgehammer to crack a nut. I wanted something:</p><ul><li>Small and focused</li><li>Easily customizable at every core element</li><li>Built on top of a community-trusted library (react-select) so I didn’t have to reinvent everything</li><li>That cleanly handles dynamic fetching of options as the user types</li></ul><p>Basically: “Don’t reinvent the wheel, just make it spin better.”</p><h3>What does the component do?</h3><p>At its core, the component wraps react-select but extends it with a <strong>custom React hook</strong> that manages:</p><ul><li>Fetching options dynamically based on user input</li><li>Loading and error states during fetch</li><li>Keeping the component simple and clean by hiding fetching logic inside the hook</li><li>Handling selected option state externally for better control</li></ul><p>Because it’s built on react-select, it inherits all its powerful features — keyboard accessibility, multiple customization points, and great UX.</p><h3>How does it work?</h3><p>The magic happens inside the <strong>custom hook</strong>. It abstracts away the complex async fetching and state management:</p><ul><li>When the user types, it triggers an async fetch of options</li><li>It manages loading state to provide UI feedback</li><li>Keeps track of the currently selected option</li><li>Exposes clean callbacks to the component for controlling selection</li></ul><p>This lets the autocomplete component focus purely on rendering and styling (using TailwindCSS), while the hook handles data flow.</p><h3>Challenges &amp; quirks</h3><p>No software is perfect, right? Some behaviors of react-select can be tricky, especially with async loading and custom hooks. I’ve documented these quirks inside the codebase, linking to GitHub issues and possible fixes, so anyone using this component knows what to expect and how to improve it.</p><p>Transparency is key — plus, sharing problems is half the debugging fun!</p><h3>Ready to try it?</h3><p>If you want to see the component in action, check out the live demo here:</p><p><a href="https://youtu.be/Bbo-5aHNwgA">https://youtu.be/Bbo-5aHNwgA</a></p><p>And the full source code is available on GitHub for you to explore or contribute:<br> 👉 <a href="https://github.com/18charmi/react-select-autocomplete">GitHub Repository</a></p><p>Feel free to use it as a reference or starting point for your own projects — and I’m open to feedback or suggestions!</p><h3>Final thoughts</h3><p>Building reusable components is like crafting the perfect coffee — a little effort upfront means a lot more energy later.</p><p>And hey, if you ever feel your code is too slow, just remember:</p><blockquote><em>Debugging: Being the detective in a crime movie where you are also the murderer.</em></blockquote><p>Happy coding!</p><p>If you found this helpful, check out the repo and follow me for more React and TypeScript projects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=817845f3f89c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Getting Started with Playwright Test Automation in Saleor Dashboard]]></title>
            <link>https://medium.com/@12charmi/getting-started-with-playwright-test-automation-in-saleor-dashboard-7a97d021cd88?source=rss-64acd8e87e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a97d021cd88</guid>
            <category><![CDATA[qa-engineering]]></category>
            <category><![CDATA[saleor]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[open-source-testing-tools]]></category>
            <category><![CDATA[playwright-automation]]></category>
            <dc:creator><![CDATA[Charmi Vyas]]></dc:creator>
            <pubDate>Sun, 04 May 2025 18:28:55 GMT</pubDate>
            <atom:updated>2025-05-04T18:28:55.482Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*PO2yrfvd-KcuCXW4.gif" /><figcaption>source : <a href="https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExeHd6MGNqY3hvcWd5enA0bG0zOXA4NXZ1em1jZHF0MXdpbWY4eTdnMiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/HCGezGpvQtDr93jr1T/giphy.gif">giphy</a></figcaption></figure><p>Let’s face it — manually clicking around your dashboard to test features is fun the first time… and unbearable the 37th.<br>Enter: <strong>Playwright</strong> — your automated testing bestie that never sleeps, complains, or forgets where the “Login” button is.</p><p>In this post, I’ll walk you through how <strong>Playwright E2E automation</strong> is implemented in <strong>Saleor’s dashboard - </strong><a href="https://github.com/saleor/saleor-dashboard">https://github.com/saleor/saleor-dashboard</a>, including real-world configurations, project setup, session handling, and role-based testing.<br> We’ll learn it the nerdy way, but with a few jokes to keep your soul intact. 😄</p><h3>🧠 Pre-Flight Checklist: Stuff to Know Before Liftoff</h3><p>Before jumping into the test automation galaxy, here are a few resources to warm up with:</p><ul><li><strong>VSCode Playwright Extension</strong><br> <a href="https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright">Install it</a> to make your IDE Playwright-friendly.</li><li><strong>E2E Testing with Playwright (Video)</strong><br> Watch this <a href="https://www.youtube.com/watch?v=4-LwodVujTg">helpful intro</a>. Think of it as the trailer before the main movie.</li><li><strong>BDD (Behavior Driven Development)</strong><br> <a href="https://www.youtube.com/watch?v=ydddSkVz_a8">This video</a> explains BDD, where tests are written in plain English like:</li><li>“Given I have credentials, When I login, Then I access the dashboard.</li><li>Basically: user stories meet automation. Shakespeare meets Selenium.</li></ul><h3>🎭 What Is Playwright (And Why Should You Care)?</h3><p><a href="https://playwright.dev/">Playwright</a> is an open-source framework built by Microsoft for automating modern web apps.<br> It supports all major browsers, lets you write tests in JavaScript/TypeScript, and can handle complex flows like a ninja QA.</p><p>It’s like Selenium, but cooler, faster, and less dramatic.</p><h3>🛠 Setup: Where the Magic Begins</h3><p>Here are the main files you’ll want to check out to understand how Playwright is set up in <a href="https://github.com/saleor/saleor-dashboard">Saleor</a> :</p><ul><li><strong>playwright.config.ts</strong><br> The brain of the test suite. Here you configure test directories, environments, and browser options.</li><li><strong>package.json</strong><br> Playwright gets added to dependencies, and you’ll see some cool scripts like:</li><li>qa:pw-e2e – Runs all tests with @e2e in the title from the command line.</li><li>qa:pw-ui – Runs tests in the browser. Great for debugging or pretending you’re doing magic.</li><li><strong>testDir</strong> (typically playwright/tests)<br> This is your test HQ. Every .spec.ts file in here is a test case waiting to be launched.</li></ul><h3>🧪 Organizing Tests with Projects</h3><p>In the playwright.config.ts, Saleor uses <strong>projects</strong> to logically group test runs.<br> Each project can have its own settings and dependencies.</p><p>Example:</p><pre>projects: [<br>  {<br>    name: &quot;setup&quot;,<br>    testMatch: [&quot;auth.setup.ts&quot;]<br>  },<br>  {<br>    name: &quot;admin-tests&quot;,<br>    dependencies: [&quot;setup&quot;],<br>    testMatch: [&quot;admin/**.spec.ts&quot;]<br>  }<br>]</pre><p>Why do this?</p><ul><li>Control test order (because “Login test” should come <em>before</em> “Test admin actions,” obviously).</li><li>Share setup across multiple test groups.</li><li>Avoid test chaos. Nobody likes test chaos.</li></ul><h3>🔐 Handling Login &amp; Authorization: The VIP Entrance</h3><p>Authentication in E2E is always tricky. But Saleor handles it like a pro:</p><h4>auth.setup.ts — The Doorman of Your Tests</h4><p>This file:</p><ul><li>Logs in using the API.</li><li>Uses .env for credentials.</li><li>Stores the session at playwright/.auth/admin.json.</li></ul><p>And it only runs <strong>once</strong> when tests start.</p><blockquote><em>So your tests don’t have to click the Login button 600 times. Playwright isn’t your intern.</em></blockquote><h4>What About UI Mode?</h4><p>If you’re running tests in UI mode (i.e., with qa:pw-ui), make sure to <strong>manually trigger the setup</strong> before running other tests.<br> Otherwise, tests will just stare blankly at the login page. 🫠</p><h3>👥 Role-Based Sessions: Testing Like a Boss (or a Viewer)</h3><p>Need to test different user roles? Saleor uses a custom fixture:</p><h4>testWithPermission.ts — Your Role-Playing Friend</h4><ul><li>This fixture gives you a user session with the required permission (e.g., &quot;admin&quot;, &quot;staff&quot;, etc.)</li><li>Usage:</li></ul><pre>import { test } from &quot;utils/testWithPermission&quot;; <br><br>test.use({ permissionName: &quot;admin&quot; });<br><br>test(&quot;&quot;, () =&gt; {});</pre><ul><li>Fixtures are like reusable test helpers. If you write the same session logic twice, Playwright will judge you silently.</li></ul><p>📺 <a href="https://www.youtube.com/watch?v=3i6cJUFO_m4">Watch how fixtures work</a></p><h3>📄 Clean Code with Page Object Model (POM)</h3><p>Remember when your UI changed and 10 test files broke?<br> That’s why we use the <strong>Page Object Model</strong> (POM).</p><ul><li>Each page gets its own class.</li><li>Tests use these classes instead of writing raw selectors.</li><li>So when the UI changes, you only update <strong>one</strong> file. And your future self sends you a thank-you text.</li></ul><blockquote><em>“Clean tests &gt; Broken tests &gt; No tests” — Ancient QA proverb.</em></blockquote><p>👉 <a href="https://playwright.dev/docs/pom#introduction">More on POM</a></p><h3>🧪 Sample Test Breakdown</h3><p>Here’s what a typical test file (service.spec.ts) might look like:</p><pre>import { test } from &quot;utils/testWithPermission&quot;;<br>import { ServicePage } from &quot;pages/ServicePage&quot;;</pre><pre>test.use({ permissionName: &quot;admin&quot; });</pre><pre>test.describe(&quot;Service Page Tests&quot;, () =&gt; {<br>  let page: ServicePage;</pre><pre>  test.beforeEach(async ({ page: browserPage }) =&gt; {<br>    page = new ServicePage(browserPage);<br>  });</pre><pre>  test(&quot;should create a new service&quot;, async () =&gt; {<br>    await page.navigate();<br>    await page.createService(&quot;Fast Delivery&quot;);<br>    await page.verifyServiceExists(&quot;Fast Delivery&quot;);<br>  });<br>});</pre><ul><li>Use beforeEach to set up the page.</li><li>Keep your tests short, clear, and focused.</li><li>Let page objects do the heavy lifting.</li></ul><h3>⚡ Bonus: Let Playwright Write Tests For You (Seriously)</h3><p>Too lazy to write the first draft of your test?<br> Use Playwright’s <strong>Codegen</strong>:</p><pre>npx playwright codegen</pre><p>It opens two windows:</p><ul><li>A browser for clicking around.</li><li>An inspector that magically writes code while you interact.</li></ul><p>It’s like pair programming with an invisible friend who never argues.</p><p>👉 <a href="https://playwright.dev/docs/codegen-intro#introduction">Playwright Codegen Intro</a></p><h3>✅ Final Thoughts: Test Smart, Sleep Better</h3><p>Using Playwright in Saleor isn’t just about writing tests.<br> It’s about:</p><ul><li>Creating reliable automation.</li><li>Reusing setups for performance.</li><li>Testing different user roles without reinventing the wheel.</li><li>Keeping code clean and DRY with POM.</li></ul><p>Whether you’re building new features or refactoring old ones, these practices will help you deploy with confidence — and without crossing your fingers.</p><p>Thanks for reading! If this guide helped, give it a few claps and share it with your QA buddy (or that dev who still tests by clicking everything manually).<br>Remember: <strong>You don’t have to test harder — just smarter.</strong> 🧠✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a97d021cd88" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>