<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Alleluia Izimpamvu</title>
    <description>The latest articles on Forem by Alleluia Izimpamvu (@aizimpamvu).</description>
    <link>https://forem.com/aizimpamvu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F746556%2F3022a349-60b6-47f2-9c3c-dc70f9f4b476.jpeg</url>
      <title>Forem: Alleluia Izimpamvu</title>
      <link>https://forem.com/aizimpamvu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aizimpamvu"/>
    <language>en</language>
    <item>
      <title>Data-Driven API testing with Playwright: Step-by-step 👨🏼‍💻🐞</title>
      <dc:creator>Alleluia Izimpamvu</dc:creator>
      <pubDate>Thu, 05 Sep 2024 14:44:53 +0000</pubDate>
      <link>https://forem.com/aizimpamvu/data-driven-api-testing-with-playwright-step-by-step-25lg</link>
      <guid>https://forem.com/aizimpamvu/data-driven-api-testing-with-playwright-step-by-step-25lg</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In modern web development, ensuring that your API behaves as expected in various scenarios is critical. Automated testing plays a crucial role in this process, and data-driven testing is a popular approach. This article will explore how to perform API data-driven testing using Playwright with JavaScript. We'll cover the prerequisites, and setup process, and provide a step-by-step guide to implementing a test script that validates API responses against predefined data. Additionally, we'll demonstrate how to retrieve specific user data by using the Users and Posts open APIs as examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;Before diving into the setup, ensure that you have the following prerequisites installed:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Install Node.js 18+
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;npm i node@lts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also download it from the official &lt;a href="https://nodejs.org/en" rel="noopener noreferrer"&gt;Node.js website&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Install playwright
&lt;/h3&gt;

&lt;p&gt;You can read my previous article on Playwright installation 👉🏽&lt;a href="https://dev.to/aizimpamvu/automation-testing-with-playwright-47ml"&gt;here&lt;/a&gt; or read more information about playwright on the official &lt;a href="https://playwright.dev/docs/intro" rel="noopener noreferrer"&gt;Playwright website&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Set up dotenv
&lt;/h3&gt;

&lt;p&gt;We will use dotenv to load environment variables from a &lt;strong&gt;.env&lt;/strong&gt; file. This will help keep the API URLs and sensitive data like API keys or tokens out of the code whenever necessary.&lt;/p&gt;

&lt;p&gt;Install  &lt;code&gt;dotenv&lt;/code&gt; with the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install dotenv --save&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;More information about the package Is found 👉🏽&lt;a href="https://www.npmjs.com/package/dotenv" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  API Test Script 🧑‍💻
&lt;/h2&gt;

&lt;p&gt;In this section, we'll will explain the playwright config file and write a Playwright test script to verify API endpoints if the response is Ok(200). The script performs two key actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetches a list of users and finds a user with ID 7.&lt;/li&gt;
&lt;li&gt;Retrieves posts and filters them by User ID 7.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After we will explain each line of the code&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Playwright Config file
&lt;/h3&gt;

&lt;p&gt;Normally while you install Playwright this file name &lt;code&gt;playwright.config.js&lt;/code&gt; has configuration about the browsers, default test folder, retries etc. you can delete the existing config and write API config as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { defineConfig } from "@playwright/test";
import 'dotenv/config';

export default defineConfig({
    use:{
        baseURL: process.env.URL ,
        extraHTTPHeaders:{
          //Here you will pass all headers, if you have authentication token you can do it here
            'Content-Type': 'application/json',

        }
    },
    trace: 'on-first-retry',
    headless:true,
    retries:2,
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Write test scripts
&lt;/h3&gt;

&lt;p&gt;Inside the &lt;code&gt;tests&lt;/code&gt; directory,  create a file &lt;code&gt;*.spec.js&lt;/code&gt; and below is the code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { test, expect } from "@playwright/test";
import 'dotenv/config';

test.describe(" User and Post API Tests", () =&amp;gt; {
    test("Getting the List of the Users and getting user with ID 7", async ({ request }) =&amp;gt; {
        // Make the API request to get users
        const res = await request.get(`${process.env.URL}/users`);

        // Validate response status and body
        expect(res.status()).toBe(200);
        expect(res.ok()).toBeTruthy();

        // Parse the response body
        const users = await res.json();

        // Find the user with ID 7
        const user = users.find(user =&amp;gt; user.id === 7);
        if (!user) {
            console.error("User with ID 7 not found");
            return;
        }

        // Log the username for verification
        const username = user.name;
        console.log(`Username: ${username}`);

        // Store username in process.env for the next test to use
        process.env.USERNAME = username;
    });

    test("Testing getting Posts and posts by User ID 7", async ({ request }) =&amp;gt; {
        const username = process.env.USERNAME;

        // Check if username is available
        if (!username) {
            console.error("Username not found. Make sure the user test ran successfully.");
            return;
        }

        console.log(`Posts by ${username}`);
        console.log('-------------------------');

        // Make the API request to get posts
        const res = await request.get(`${process.env.URL}/posts`);

        // Validate response status and body
        expect(res.status()).toBe(200);
        expect(res.ok()).toBeTruthy();

        // Parse the response body
        const posts = await res.json();

        // Filter posts to only include those with userId equal to 7
        const userPosts = posts.filter(post =&amp;gt; post.userId === 7);

        for (const post of userPosts) {
            console.log(`Post ID: ${post.id}, Title: ${post.title}`);
        }
    });
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Script breakdown
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Section 1: Importing Required Dependencies
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsql1pz3kw82ggsxmwntr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsql1pz3kw82ggsxmwntr.png" alt="Importing Dependencies" width="800" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@playwright/test&lt;/code&gt;: This is Playwright's testing framework. We use its test and expect functions to write test cases and assertions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dotenv/config&lt;/code&gt;: Loads environment variables from a .env file, allowing us to access sensitive data like API URLs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Section 2: Describing the test suite
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftpxryan3qx7tp3dfsdto.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftpxryan3qx7tp3dfsdto.png" alt="Describing the test suite" width="800" height="137"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This block defines a test suite named "User and Post API Tests". The &lt;code&gt;test.describe&lt;/code&gt; function groups related tests. &lt;/p&gt;

&lt;h4&gt;
  
  
  Section 3: First Test case: Fetching Users and Retrieving Specific User
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc07k0qoqj8env09eozrh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc07k0qoqj8env09eozrh.png" alt="First Test case" width="800" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We are fetching all users and retrieving the details  of the user with id 7&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;async ({ request })&lt;/code&gt; allows Playwright to handle HTTP requests asynchronously.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Making API request to get all users we use &lt;code&gt;request.get()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Validating the response and check that the API status code is 200 which indicate that success using this code line  &lt;code&gt;expect(res.status()).toBe(200)&lt;/code&gt; and &lt;code&gt;res.ok()&lt;/code&gt; to confirm that the request was successful&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parsing the Response Body using &lt;code&gt;.json()&lt;/code&gt; method parses the response into a JavaScript object. We can now access individual users within the &lt;code&gt;users&lt;/code&gt; array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find the user with id 7 and store the username in .env file for future use in the other test cases( from &lt;code&gt;line 17-18&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Section 4:Fetching Posts and Filtering by User ID
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkmwo8un5clz1iu4yx13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkmwo8un5clz1iu4yx13.png" alt="Fetching Post" width="800" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mostly scripts are the same as previous test cases except that here we are getting posts and filtering in posts and returning only the posts of a specific user. Therefore we will focus on filtering part&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We parse the response and then use &lt;code&gt;filter()&lt;/code&gt; to retrieve posts where userId equals 7, which refers to the specific user we’re testing&lt;/li&gt;
&lt;li&gt;For each post authored by the user, we log its &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;title&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Running the Tests
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;npx playwright test&lt;/code&gt; : This will trigger the Playwright test suites and all files under the tests folder or your default directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This test suite automates fetching user data and their related posts from an API. By breaking the process into small, reusable components, we ensure modularity and maintainability. Playwright's API testing capabilities, combined with environment variables, make it easier to automate API interactions and adapt to different environments.&lt;br&gt;
&lt;a href="https://github.com/aizimpamvu/api-data-driven-test/tree/main" rel="noopener noreferrer"&gt;👉🏽Here is the link to github repo for the source code&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nodejs.org/en" rel="noopener noreferrer"&gt;Node js Official website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://playwright.dev/docs/intro" rel="noopener noreferrer"&gt;Playwright documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/dotenv" rel="noopener noreferrer"&gt;dotenv library&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy testing!!🎭&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>automation</category>
      <category>javascript</category>
      <category>testing</category>
    </item>
    <item>
      <title>Automation testing with Playwright</title>
      <dc:creator>Alleluia Izimpamvu</dc:creator>
      <pubDate>Thu, 27 Jun 2024 16:16:37 +0000</pubDate>
      <link>https://forem.com/aizimpamvu/automation-testing-with-playwright-47ml</link>
      <guid>https://forem.com/aizimpamvu/automation-testing-with-playwright-47ml</guid>
      <description>&lt;h2&gt;
  
  
  Why Playwright?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Cross-language: JavaScript, TypeScript, Python, .NET, Java&lt;/li&gt;
&lt;li&gt;Cross-platform: Windows, Linux, macOS, and support headed and headless mode&lt;/li&gt;
&lt;li&gt;Cross-browser: Chromium, Webkit, and Firefox&lt;/li&gt;
&lt;li&gt;Auto-wait&lt;/li&gt;
&lt;li&gt;Codegen: Record your actions and save them in  your language&lt;/li&gt;
&lt;li&gt;Trace Viewer: Capture all information to investigate the test failure&lt;/li&gt;
&lt;li&gt;And many more...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Node.js 18 +&lt;/li&gt;
&lt;li&gt;VScode(To have a better experience by using the playwright extension)&lt;/li&gt;
&lt;li&gt;Basic programming skills &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open the terminal and run the below command&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;npm init playwright@latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2.Choose JavaScript(default is TypeScript)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbud4wiiqk16i3ecebe8f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbud4wiiqk16i3ecebe8f.png" alt="Image description" width="800" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.Choose where you want to save your tests and hit Enter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13qihxp1euq1ww47ckwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F13qihxp1euq1ww47ckwg.png" alt="Image description" width="800" height="117"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4.Add a GitHub Actions to easily run tests on CI( Select false)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81d8qprgth4eaqe1nci4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F81d8qprgth4eaqe1nci4.png" alt="Image description" width="800" height="117"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5.Install Playwright browsers and hit Enter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbzgx7mbweatb00qp57b6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbzgx7mbweatb00qp57b6.png" alt="Image description" width="749" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6.Install Playwright operating system dependencies(No is a default) hit Enter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2hn7a7m0gy3wk28em91.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2hn7a7m0gy3wk28em91.png" alt="Image description" width="749" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7.Congratulations you have successfully installed Playwright&lt;/p&gt;

&lt;h2&gt;
  
  
  Write the first test scripts
&lt;/h2&gt;

&lt;p&gt;We are going to use the  playwright's example and&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Import test and expect arguments from playwright&lt;/li&gt;
&lt;li&gt;Open playwright &lt;strong&gt;URL&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Verify that the page title has Playwright&lt;/li&gt;
&lt;li&gt;Click on Get Started &lt;/li&gt;
&lt;li&gt;Verify that Installation text is visible&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Code Snippet&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*Importing test which help you to write test cases */
/*Importing expect which help to validate expected result */
const { test, expect } = require('@playwright/test');

/* Open Playwright url*/
test('has title', async ({ page }) =&amp;gt; {
  await page.goto('https://playwright.dev/');

  // Expect a title "to contain" a substring.
  await expect(page).toHaveTitle(/Playwright/);
});

test('get started link', async ({ page }) =&amp;gt; {
  await page.goto('https://playwright.dev/');

  // Click the get started link.
  await page.getByRole('link', { name: 'Get started' }).click();

  // Expects page to have a heading with the name of Installation.
  await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code Screenshot&lt;/strong&gt; &lt;em&gt;for better visibility&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffygew7ij4g0quop5kfzr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffygew7ij4g0quop5kfzr.png" alt="Image description" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the test
&lt;/h2&gt;

&lt;p&gt;Run: &lt;code&gt;npx playwright test&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command will run all the tests under test Directory which is tests &lt;/p&gt;

&lt;h2&gt;
  
  
  Display playwright test report
&lt;/h2&gt;

&lt;p&gt;Run: &lt;code&gt;npx playwright show-report&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Below is the sample of playwright HTML report&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdncdt6q0usrm8mxawvux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdncdt6q0usrm8mxawvux.png" alt="Image description" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy testing!!🎭&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>testing</category>
      <category>softwareengineering</category>
      <category>qa</category>
    </item>
  </channel>
</rss>
