How to Generate Different Test Reports in Playwright?

How to Generate Different Test Reports in Playwright?

Playwright offers a flexible reporting system that allows you to generate various types of reports to suit your needs. Here's a breakdown of the available options:

Built-in Reporters

Playwright comes with several built-in reporters that can be easily configured:

  • List: Provides a simple text-based report in the terminal.
  • JSON: Generates a JSON file containing detailed test results.
  • HTML: Creates an interactive HTML report with test summaries, failures, and screenshots.
  • JUnit: Generates a JUnit XML report for integration with CI/CD pipelines and other tools.
  • Line: Outputs a single line summary of the test results.


Step1; Let's generate most commonly used test reports, Create a spec file with test

// Include playwright module
const { test, expect } = require('@playwright/test');

// Write a test
test('Validate Youtube title', async ({ page }) => {
    // Go to URL
    await page.goto('https://www.youtube.com/')

    // Search with keywords
    await page.getByPlaceholder('Search').click();
    await page.getByPlaceholder('Search').fill('cypress by testers talk');

    await expect(page.getByRole('button', { name: 'Search', exact: true })).toBeEnabled();
    await page.getByRole('button', { name: 'Search', exact: true }).click();

    await page.waitForTimeout(2000);

    // Click on playlist
    await page.getByRole('link', { name: 'Cypress by Testers Talk' }).click();

    // Validate title
    await expect(page).toHaveTitle('Cypress Tutorial Full Course 2023 | Learn Cypress in 5 Hrs - YouTube');
})        

Step2: Open playwright.config.js file, add html, allure-report, list, junit, json, list etc.

playwright.config.js

Step3: Run the test using below command

'npx playwright test        

Step4: html report generated

html test report

Step5: Allure report generated - To get html report you need to run additional commands

allure report

Step6: Junit & JSON report generated

junit & json report

Step7: list report is generated.

list report

Reference: https://playwright.dev/docs


TO RECEIVE DAILY UPDATES, SUBSCRIBE CHANNEL - https://www.youtube.com/c/BakkappaN_SoftwareTesting_Videos?sub_confirmation=1


===== Playwright Automation Full Courses =====

-> Playwright Full Course - https://youtube.com/playlist?list=PLUeDIlio4THEgPRVJRqZRS8uw8hhVNQCM&si=65JRAAG-SkkfphDm

-> Playwright API Testing Crash Course - https://youtube.com/playlist?list=PLUeDIlio4THF3rnYZ63qkbHwMTXiG67vz&si=hNd_ji_kXVmIAr_R

-> Playwright with Azure DeveOps Pipeline - https://youtube.com/playlist?list=PLUeDIlio4THG8irTXJn-Z02nYzmi6dUOF&si=3b4G5tvemlPy0--j

-> Playwright with CRM application testing - https://youtu.be/WwovRRp0f4o?si=w0rzJlUI9BhfP4KS


===== Playwright GitHub Repositories =====

-> Playwright Full Course - https://github.com/BakkappaN/PlaywrightTutorialFullCourse

-> Playwright API Testing Crash Course - https://github.com/BakkappaN/PlaywrightAPITestingTutorial

-> Playwright with Azure DeveOps Pipeline - https://github.com/BakkappaN/PlaywrightAzureDevopsPipeline

-> Playwright with CRM application testing -https://github.com/BakkappaN/MicrosoftD365CRMPlaywrightFramework

-> Playwright with JavaScript Framework [UI + API] - https://github.com/BakkappaN/PlaywrightBaseAutomationFramework

-> Playwright with TypeScript Framework [UI + API]- https://github.com/BakkappaN/Playwright-TypeScript-Framework


Learn more about Playwright:


-> Playwright API Testing Crash Course


-> Playwright with Azure DevOps Complete guide


-> Testing Microsoft CRM application using Playwright


#playwright #apitesting #qa #softwaretesting #crm #javascript #typescript #ado #azuredeveops #framework #fullcourse #codegen #test #e2e #testing #automation #testerstalk #bakkappan #git #github #testautomation #selenium #cypress #microsoftplaywright #microsoft #opensource


SUBSCRIBE CHANNEL TO GET LATEST SOFTWARE TESTING UPDATES - https://www.youtube.com/c/BakkappaN_SoftwareTesting_Videos?sub_confirmation=1



要查看或添加评论,请登录

Bakkappa N的更多文章

社区洞察

其他会员也浏览了