{"id":18330209,"url":"https://github.com/krishnapollu/playwright-nodejs-poc","last_synced_at":"2026-04-29T12:33:21.701Z","repository":{"id":187150158,"uuid":"676390367","full_name":"krishnapollu/playwright-nodejs-poc","owner":"krishnapollu","description":"A sample NodeJS suite which runs cross browser tests using Playwright","archived":false,"fork":false,"pushed_at":"2024-01-31T03:47:15.000Z","size":8920,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-23T01:46:45.980Z","etag":null,"topics":["chromium","cross-browser-testing","firefox","nodejs","playwright","playwright-javascript","test-automation","web-automation-testing","webkit"],"latest_commit_sha":null,"homepage":"https://krishnapollu.github.io/playwright-nodejs-poc/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krishnapollu.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-09T05:10:16.000Z","updated_at":"2023-08-11T17:38:30.000Z","dependencies_parsed_at":"2024-01-31T04:50:43.252Z","dependency_job_id":null,"html_url":"https://github.com/krishnapollu/playwright-nodejs-poc","commit_stats":null,"previous_names":["krishnapollu/playwright-nodejs-poc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/krishnapollu/playwright-nodejs-poc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krishnapollu%2Fplaywright-nodejs-poc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krishnapollu%2Fplaywright-nodejs-poc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krishnapollu%2Fplaywright-nodejs-poc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krishnapollu%2Fplaywright-nodejs-poc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krishnapollu","download_url":"https://codeload.github.com/krishnapollu/playwright-nodejs-poc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krishnapollu%2Fplaywright-nodejs-poc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32426578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T12:24:25.982Z","status":"ssl_error","status_checked_at":"2026-04-29T12:24:24.439Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chromium","cross-browser-testing","firefox","nodejs","playwright","playwright-javascript","test-automation","web-automation-testing","webkit"],"created_at":"2024-11-05T19:21:08.183Z","updated_at":"2026-04-29T12:33:21.683Z","avatar_url":"https://github.com/krishnapollu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **playwright-nodejs-poc** \n\nA sample project to run cross browser tests using Playwright.\nPage Object Model deisgn pattern\nUses SwagLabs demo app for test execution\n\n## Clone the project\n`` git clone https://github.com/krishnapollu/playwright-nodejs-poc.git ``\n\n## Install project\n`` npm install ``\n\n## Run tests\n- headless\n`` npx playwright tests ``\n- headed\n`` npx playwright tests --headed ``\n\n## Reports\n\n#### Default Playwright Reports\n- `` npx playwright show-report ``\n\nPlaywright Reports can be viewed [here](https://krishnapollu.github.io/playwright-nodejs-poc/)\n\n#### Allure Integration\n\nInstall allure reportet for playwright\n- `` npm i -D @playwright/test allure-playwright `` \n\nUpdate playwright.config.js\n```js\nreporter: [\n    ['html'], \n    ['allure-playwright', {\n      detail: true,\n      suiteTitle: false,\n    }]\n  ],\n```\n\nReporting Util\n```js\nexports.ReportUtil = class ReportUtil {\n\n    constructor(page, testInfo){\n        this.page = page;\n        this.testInfo = testInfo;\n    }\n    async takeScreenshot(){\n        await this.testInfo.attach(\"login success\", {\n            body: await this.page.screenshot(),\n            contentType: \"image/png\",\n          });\n    }\n};\n```\n\nAdd attachment from code\n```js\nthis.ru = new ReportUtil(this.page, this.testInfo);\n...\nawait this.ru.takeScreenshot();\n```\n\nGenerate and View Allure report\n- `` allure serve ``\n\n\n## Accessibility Tests\n\nAn important Playwright feature which enables you to run Accessibility Tests on your web page and validate the violations.\nIn this project, I run the accessibility test and attach the report as JSON, instead of failing the test upfront if any violations are present.\n\n#### Fixture\n```js\n// fixtures/myAccFixture.js\n\n//from playwright documentation\n\nexports.test = base.test.extend({\n  makeAxeBuilder: async ({ page }, use, testInfo) =\u003e {\n    const makeAxeBuilder = () =\u003e new AxeBuilder({ page })\n        .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'])\n        .exclude('#commonly-reused-element-with-known-issue');\n    await use(makeAxeBuilder);\n  }\n});\nexports.expect = base.expect;\n```\n\n#### In Reporting Util\n```js\n//attach the accessibility results as JSON in playwright-report\n\nasync attach(accessibilityScanResults, testInfo) {\n        await testInfo.attach('accessibility-scan-results', {\n            body: JSON.stringify(accessibilityScanResults, null, 2),\n            contentType: 'application/json'\n          });\n    }\n```\n#### Usage\n```js\n// import the fixture and reporting util\nconst { test, expect } = require('../../fixtures/myAccFixture');\nconst { ReportUtil } = require('../utils/reporting-utils');\n...\ntest('Accessibility Test', async ({ page, makeAxeBuilder }, testInfo) =\u003e {\n    let ru = new ReportUtil(page, testInfo);\n    let accessibilityScanResults = {};\n...\n    accessibilityScanResults = await makeAxeBuilder().analyze(); // runs the accessibility test on current page context\n    ru.attach(accessibilityScanResults, testInfo); // attaches the results as JSON in report\n```\n\n## API Tests\nPlaywright lets you write API tests as easily as below\n```js\ntest('GET Users', async ({ request }) =\u003e {\n        const response = await request.get(`${baseUrl}/users/3`);\n        expect(response.status()).toBe(200);\n    })\n```\n\n## Custom Logging\nI have integrated Winston node module to implement logging.\n\n#### Logger Util\n```js\ncreateLogger({\n    transports: [\n        new transports.Console({\n            level: 'info',\n           ...\n        }),\n        new transports.File({\n            filename: 'logs/winston.log', \n            level: 'info',\n            maxsize: 5242880,\n            ... \n        })\n    ]\n})\n\n```\n\n#### Usage\n```js\nimport { Logger } from '../utils/Logger';\n...\nlet logger;\n...\ntest.beforeEach( async ({page}, testInfo) =\u003e { // instantiate inside the hook\n        logger = Logger(testInfo.project.name);\n    });\n...\ntest('TC01', async ({ page }) =\u003e {\n        logger.info('Printing Browser Console logs: ');\n```\n\n#### Output\n```\n2023-08-12T19:49:29.343Z [chromium] info: Printing Browser Console logs: \n```\n\n## Microsoft Playwright Testing\nPlaywright tests can now be run on remote browsers in your Azure Microsoft Playwright Testing workspace. (This is currently in preview)\n\n#### Pre Requisites\n- An active Azure Subscription (If you dont, create a free account before you begin)\n- An Azure Microsoft Playwright Testing workspace. ( This can also be created prior to the next step by logging into your Azure account. Home \u003e Playwright Tests \u003e Create Workspace )\n\n#### Configure\n- Navigate to [Playwright Portal](https://playwright.microsoft.com/)\n- Login with your Microsoft account\n- Create a workspace (if not already created)\n- Follow the steps shown in the workspace landing page to create ``PLAYWRIGHT_SERVICE_ACCESS_TOKEN`` and ``PLAYWRIGHT_SERVICE_URL``\n- If you dont see it, you can create the same from Settings page.\n- Store the ``PLAYWRIGHT_SERVICE_ACCESS_TOKEN`` and ``PLAYWRIGHT_SERVICE_URL`` in your repository Secrets\n- Create ``playwright.service.config.ts`` file in your repository and copy the below contents to it.\n  ```ts\n            /*\n        * This file enables Playwright client to connect to remote browsers.\n        * It should be placed in the same directory as playwright.config.ts.\n        */\n        \n        import { defineConfig } from '@playwright/test';\n        import config from './playwright.config';\n        import dotenv from 'dotenv';\n        \n        // Define environment on the dev box in .env file:\n        //  .env:\n        //    PLAYWRIGHT_SERVICE_ACCESS_TOKEN=XXX\n        //    PLAYWRIGHT_SERVICE_URL=XXX\n        \n        // Define environment in your GitHub workflow spec.\n        //  env:\n        //    PLAYWRIGHT_SERVICE_ACCESS_TOKEN: ${{ secrets.PLAYWRIGHT_SERVICE_ACCESS_TOKEN }}\n        //    PLAYWRIGHT_SERVICE_URL: ${{ secrets.PLAYWRIGHT_SERVICE_URL }}\n        //    PLAYWRIGHT_SERVICE_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}\n        \n        dotenv.config();\n        \n        // Name the test run if it's not named yet.\n        process.env.PLAYWRIGHT_SERVICE_RUN_ID = process.env.PLAYWRIGHT_SERVICE_RUN_ID || new Date().toISOString();\n        \n        // Can be 'linux' or 'windows'.\n        const os = process.env.PLAYWRIGHT_SERVICE_OS || 'linux';\n        \n        export default defineConfig(config, {\n          // Define more generous timeout for the service operation if necessary.\n          // timeout: 60000,\n          // expect: {\n          //   timeout: 10000,\n          // },\n          workers: 20,\n        \n          // Enable screenshot testing and configure directory with expectations.\n          // https://learn.microsoft.com/azure/playwright-testing/how-to-configure-visual-comparisons\n          ignoreSnapshots: false,\n          snapshotPathTemplate: `{testDir}/__screenshots__/{testFilePath}/${os}/{arg}{ext}`,\n          \n          use: {\n            // Specify the service endpoint.\n            connectOptions: {\n              wsEndpoint: `${process.env.PLAYWRIGHT_SERVICE_URL}?cap=${JSON.stringify({\n                // Can be 'linux' or 'windows'.\n                os,\n                runId: process.env.PLAYWRIGHT_SERVICE_RUN_ID\n              })}`,\n              timeout: 30000,\n              headers: {\n                'x-mpt-access-key': process.env.PLAYWRIGHT_SERVICE_ACCESS_TOKEN!\n              },\n              // Allow service to access the localhost.\n              exposeNetwork: '\u003cloopback\u003e'\n            }\n          },\n          // Tenmp workaround for config merge bug in OSS https://github.com/microsoft/playwright/pull/28224\n          projects: config.projects? config.projects : [{}]\n        });\n  ```\n  \n- Update your workflow yaml as below\n  ```yml\n    env:\n          # Access token and regional endpoint for Microsoft Playwright Testing\n          PLAYWRIGHT_SERVICE_ACCESS_TOKEN: ${{ secrets.PLAYWRIGHT_SERVICE_ACCESS_TOKEN }}\n          PLAYWRIGHT_SERVICE_URL: ${{ secrets.PLAYWRIGHT_SERVICE_URL }}\n          PLAYWRIGHT_SERVICE_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}\n      - name: Run Playwright tests\n        run: npx playwright test --config=playwright.service.config.ts --workers=20 \n  ```\nThe next tine your workflow is triggered, the tests will be run on your Azure Microsoft Playwright Testing workspace. Once the execution is complete, you will be able to see the test execution metadata in your workspace Home page.\n\n#### Triggering tests from codespaces / local machine\nYou can alternatively trigger the tests from your working terminal as well. Follow the below steps:\n```shell\nexport PLAYWRIGHT_SERVICE_ACCESS_TOKEN = \u003cYOUR_PLAYWRIGHT_SERVICE_ACCESS_TOKEN\u003e\nexport PLAYWRIGHT_SERVICE_URL = \u003cYOUR_PLAYWRIGHT_SERVICE_URL\u003e\nnpx playwright test --config=playwright.service.config.ts --workers=20\n```\nOnce the execution is complete, you will be able to see the test execution metadata in your workspace Home page.\n\n- More documentation available at [Playwright-Testing](https://learn.microsoft.com/en-in/azure/playwright-testing/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrishnapollu%2Fplaywright-nodejs-poc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrishnapollu%2Fplaywright-nodejs-poc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrishnapollu%2Fplaywright-nodejs-poc/lists"}