feat(junit reporter): add attachments to stdout (#8059)
`JUnitReporter` follows the common format for attachments in JUnit reports, recognized by GitLab and Jenkins among others.
This commit is contained in:
parent
79e8592146
commit
5f297b6894
|
|
@ -153,6 +153,15 @@ class JUnitReporter implements Reporter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const attachment of result.attachments) {
|
||||||
|
if (attachment.path) {
|
||||||
|
entries.push({
|
||||||
|
name: 'system-out',
|
||||||
|
text: `[[ATTACHMENT|${path.relative(this.config.rootDir, attachment.path)}]]`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const stderr of result.stderr) {
|
for (const stderr of result.stderr) {
|
||||||
entries.push({
|
entries.push({
|
||||||
name: 'system-err',
|
name: 'system-err',
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import xml2js from 'xml2js';
|
import xml2js from 'xml2js';
|
||||||
|
import path from 'path';
|
||||||
import { test, expect } from './playwright-test-fixtures';
|
import { test, expect } from './playwright-test-fixtures';
|
||||||
|
|
||||||
test('should render expected', async ({ runInlineTest }) => {
|
test('should render expected', async ({ runInlineTest }) => {
|
||||||
|
|
@ -220,6 +221,23 @@ test('should render projects', async ({ runInlineTest }) => {
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render attachments', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'a.test.js': `
|
||||||
|
const { test } = pwt;
|
||||||
|
test.use({ screenshot: 'on' });
|
||||||
|
test('one', async ({ page }) => {
|
||||||
|
await page.setContent('hello');
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { reporter: 'junit' });
|
||||||
|
const xml = parseXML(result.output);
|
||||||
|
const suite = xml['testsuites']['testsuite'][0];
|
||||||
|
expect(suite['system-out'].length).toBe(1);
|
||||||
|
expect(suite['system-out'][0].trim()).toBe(`[[ATTACHMENT|test-results${path.sep}a-one${path.sep}test-finished-1.png]]`);
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
function parseXML(xml: string): any {
|
function parseXML(xml: string): any {
|
||||||
let result: any;
|
let result: any;
|
||||||
xml2js.parseString(xml, (err, r) => result = r);
|
xml2js.parseString(xml, (err, r) => result = r);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue