Rayrun
← Back to Discord Forum

Implementing class reporter

Hey all, I am trying to do some custom reporting and I am trying to implement https://playwright.dev/docs/api/class-reporter#reporter-on-exit I have added path to the file:

reporter: process.env.CI
    ? [['html'], ['list']]
    : [['html'], ['playwright/reporter.ts', { customOption: 'some value' }]],

and I have added to the file what is in the example:

import type {
  Reporter, FullConfig, Suite, TestCase, TestResult, FullResult
} from '@playwright/test/reporter';

class MyReporter implements Reporter {
  constructor(options: { customOption?: string } = {}) {
    console.log(`my-awesome-reporter setup with customOption set to ${options.customOption}`);
  }

  onBegin(config: FullConfig, suite: Suite) {
    console.log(`Starting the run with ${suite.allTests().length} tests`);
  }

  onTestBegin(test: TestCase) {
    console.log(`Starting test ${test.title}`);
  }

  onTestEnd(test: TestCase, result: TestResult) {
    console.log(`Finished test ${test.title}: ${result.status}`);
  }

  onEnd(result: FullResult) {
    console.log(`Finished the run: ${result.status}`);
  }
}
export default MyReporter;

but when I run tests I get code: 'ERR_PACKAGE_PATH_NOT_EXPORTED' and I am not sure what is wrong Thanks for response

This thread is trying to answer question "How to implement a custom reporter using Playwright's class reporter and how to upload the report to Bitbucket pipelines?"

5 replies

Your path to the reporter is wrong. Did you maybe forget a ./ ?

Wrong path, thank you!

regardin this https://playwright.dev/docs/api/class-reporter#reporter-on-exit is somewhere an example how to upload the report, or more how to access the report for uploading? I want to build custom upload to bitbucket pipelines

bhushan.trivedi

Do you have any idea about allure report test result generator?

not at all

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.