I have a custom reporter in Playwright which is intended to be used only to generate a report of what tests exist in my project:
import type {
FullConfig, FullResult, Reporter, Suite, TestCase, TestResult,
TestStep
} from '@playwright/test/reporter';
class MyReporter implements Reporter {
onBegin(config: FullConfig, suite: Suite) {
suite.allTests(). forEach(testCase => {
console.log(testCase.title + " [" + testCase.tags.join('; ') +"]");
});
}
}
export default MyReporter;
I currently use this with the –list argument so that no tests are executed, but in the event that someone uses this and forgets to specify –list, it runs and takes ages to complete as it’s executing every test.
Is there something I can add to the onBegin method to skip tests, like I can with test.beforeEach using testInfo so that I can run this reporter and not have to remember the right command line arguments?
So far I have tried things like pushing a @skip tag to the tags (tags appear to not be able to be updated in this context), and tried adding parameters to the onTestBegin in the same way you would when writing test.beforeEach (no such overload exists – “target signature provides too few arguments”)