{"id":15368,"library":"pw-test-logs-reporter","title":"Playwright Test Logs Reporter","description":"pw-test-logs-reporter is a specialized Playwright test reporter designed to automatically send details of failed test cases to a configurable external API endpoint. Currently at version 1.0.1, this package offers a simple, purpose-built solution for integrating Playwright's test results into external logging or incident management systems, with a specific focus on capturing and reporting only test failures. It integrates directly into Playwright's configuration via a string reference in the `reporter` array, and requires the `FAILED_TEST_RESULTS_ENDPOINT` environment variable to be set for operation. Its release cadence is likely stable and infrequent, given its targeted functionality. It differentiates itself by its singular focus on failed tests and straightforward API reporting, providing a lean alternative to more comprehensive, all-encompassing reporting solutions.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/ikoral/pw-test-logs-reporter","tags":["javascript","playwright","reporter","failed test log reporter","typescript"],"install":[{"cmd":"npm install pw-test-logs-reporter","lang":"bash","label":"npm"},{"cmd":"yarn add pw-test-logs-reporter","lang":"bash","label":"yarn"},{"cmd":"pnpm add pw-test-logs-reporter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The reporter class is exported as a default export for programmatic use or extension. Its primary usage, however, is via a string reference in the Playwright configuration.","wrong":"import { PwTestLogsReporter } from 'pw-test-logs-reporter';","symbol":"PwTestLogsReporter","correct":"import PwTestLogsReporter from 'pw-test-logs-reporter';"},{"note":"Type-only import for the reporter class, useful for TypeScript projects when not instantiating the class directly.","symbol":"PwTestLogsReporter (type)","correct":"import type { PwTestLogsReporter } from 'pw-test-logs-reporter';"},{"note":"For CommonJS environments, the class is accessed via the `.default` property due to the default export.","wrong":"const PwTestLogsReporter = require('pw-test-logs-reporter');","symbol":"PwTestLogsReporter (CommonJS)","correct":"const PwTestLogsReporter = require('pw-test-logs-reporter').default;"}],"quickstart":{"code":"import { defineConfig } from '@playwright/test';\n\nconst FAILED_ENDPOINT = process.env.FAILED_TEST_RESULTS_ENDPOINT ?? 'http://localhost:8080/api/failed-tests';\n\n// playwright.config.ts\nconst config = defineConfig({\n  testDir: './tests', // Specify your test directory\n  reporter: [\n    [\"list\"], // Standard list reporter\n    [\"pw-test-logs-reporter\"]\n  ],\n  use: {\n    // Base URL to use in actions like `await page.goto('/')`.\n    baseURL: 'http://127.0.0.1:3000',\n    trace: 'on-first-retry',\n  },\n  projects: [\n    {\n      name: 'chromium',\n      use: {\n        browserName: 'chromium',\n      },\n    }\n  ]\n});\n\nexport default config;\n","lang":"typescript","description":"This configuration shows how to add `pw-test-logs-reporter` to your Playwright test setup, alongside the standard 'list' reporter. It sets up a basic Playwright project and emphasizes the critical `FAILED_TEST_RESULTS_ENDPOINT` environment variable."},"warnings":[{"fix":"Ensure `FAILED_TEST_RESULTS_ENDPOINT` is set in your environment before running tests. Example: `export FAILED_TEST_RESULTS_ENDPOINT='https://your-api.com/failed-tests'` or in a `.env` file.","message":"The `FAILED_TEST_RESULTS_ENDPOINT` environment variable is mandatory for the reporter to function correctly. If this variable is not set, the reporter will likely fail to send any test results, and may throw an error or warning during the test run.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Run `npm install pw-test-logs-reporter` or `yarn add pw-test-logs-reporter` to install the package. Verify that it's listed in your `node_modules` and accessible to Playwright.","cause":"The package `pw-test-logs-reporter` is either not installed or Playwright cannot resolve its path.","error":"Reporter \"pw-test-logs-reporter\" cannot be found."},{"fix":"Set the `FAILED_TEST_RESULTS_ENDPOINT` environment variable in your shell or CI/CD pipeline. For example, `export FAILED_TEST_RESULTS_ENDPOINT='http://your.api.com/logs'` before running your Playwright tests.","cause":"The reporter class relies on the `FAILED_TEST_RESULTS_ENDPOINT` environment variable to determine where to send the failed test logs.","error":"Error: FAILED_TEST_RESULTS_ENDPOINT environment variable is not set."},{"fix":"If using `require()`, ensure you access the default export correctly: `const PwTestLogsReporter = require('pw-test-logs-reporter').default;`.","cause":"This typically occurs in a CommonJS environment when trying to `require()` a package that uses a default export without specifying `.default`.","error":"TypeError: Cannot read properties of undefined (reading 'default')"}],"ecosystem":"npm"}