Skip to content

Instantly share code, notes, and snippets.

View VarunSriram99's full-sized avatar

S Varun VarunSriram99

View GitHub Profile

Using reporter APIs to create custom reporters

Though Playwright offers a variety of built-in reporters for test result visualization, sometimes you may need a custom solution tailored to your specific project requirements. Thankfully, Playwright allows you to build your own custom test reporter from scratch. In this blog post, we'll dive into the process of creating a custom reporter that perfectly suits your needs.

Hierarchy of suites

Before diving deep into how to build custom reporters, we need to first understand the hierarchy in which the test cases are arranged. The diagram below gives a pictorial reresentation of the hierearchy of the suites.

image

  1. Root Suite: The top-level suite in the hierarchy represents the entire test suite for the projects. It serves as the root node from which all other suites branch.
  2. Project Suites: Under the root suite, there is a project suite for each [TestProject](https://playwri
@VarunSriram99
VarunSriram99 / prepare-commit-msg
Last active July 4, 2023 14:21
Pre-commit hook to prefix the jira issue number to commit message using bash
#!/bin/sh
# Get current branch name
branch_name="$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)"
# Replace or add the board name abbreviations here
jira_abbreviations=("JIRA_BOARD_ABBREVIATION")
# Check if current branch is a feature branch i.e. starts with a ticket number
check_is_issue_branch () {
for abbrv in "${jira_abbreviations[@]}"
@VarunSriram99
VarunSriram99 / prepare-commit-msg
Last active July 4, 2023 09:24
Pre-commit hook to prefix the jira issue number to commit message using ruby
#!/usr/bin/env ruby
class PrepareCommitMsgHandler
JIRA_PROJECT_ABBREVIATIONS = ["JIRA_BOARD_ABBRV"].freeze # Replace JIRA_BOARD_ABBRV with you Jira board abbreviation
def handle
filepath = ARGV[0]
commit_file = File.open(filepath, "r")
commit_message = commit_file.read
update_commit_message(commit_message, filepath) if is_issue_branch? && !is_commit_prefixed?(commit_message)