Closed python012 closed 9 months ago
If I understand you correctly, this is about the junit reporter. What you can do there is either create a custom reporter, which you put after the junit reporter. It looks like this:
// config
reporter: [['html'], ['junit', { outputFile: './foo.xml'}], ['./custom']],
// reporter.ts
import type { FullConfig, FullResult, Reporter, Suite } from '@playwright/test/reporter';
import { existsSync } from 'fs';
class MyReporter implements Reporter {
private _config: FullConfig;
onBegin(config: FullConfig, suite: Suite) {
this._config = config;
}
async onEnd(result: FullResult) {
const xmlFile = this._config.reporter[1][1].outputFile
// read and upload it somewhere.
console.log(`Finished the run: ${result.status}`, existsSync(this._config.reporter[1][1].outputFile));
}
}
export default MyReporter;
or you just execute a custom Node.js script after your test execution has finished.
Would that work for you?
thanks so much! I'll take a try
Hi, is it possible to call a function within a Playwright(TypeScript) test project after tests are finished and test report xml file is generated?
In my project, I'd like to import test result file to Jira, which need send a POST REQUEST to specific Jira endpoint, but looks like generating test result xml file is almost the very last step in the task of
npx playwright test
.