mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat: addition of tags to JSON reporter output (#8920)
This commit is contained in:
parent
fc972fcadd
commit
d82cb9a2ff
@ -44,6 +44,7 @@ export interface JSONReportSuite {
|
||||
suites?: JSONReportSuite[];
|
||||
}
|
||||
export interface JSONReportSpec {
|
||||
tags: string[],
|
||||
title: string;
|
||||
ok: boolean;
|
||||
tests: JSONReportTest[];
|
||||
@ -203,6 +204,7 @@ class JSONReporter implements Reporter {
|
||||
return {
|
||||
title: test.title,
|
||||
ok: test.ok(),
|
||||
tags: (test.title.match(/@[\S]+/g) || []).map(t => t.substring(1)),
|
||||
tests: [ this._serializeTest(test) ],
|
||||
...this._relativeLocation(test.location),
|
||||
};
|
||||
|
||||
@ -139,6 +139,35 @@ test('should show steps', async ({ runInlineTest }) => {
|
||||
expect(result.report.suites[0].specs[0].tests[0].results[0].steps[1].error).not.toBeUndefined();
|
||||
});
|
||||
|
||||
test('should display tags separately from title', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = pwt;
|
||||
test('math works! @USR-MATH-001 @USR-MATH-002', async ({}) => {
|
||||
expect(1 + 1).toBe(2);
|
||||
await test.step('math works in a step', async () => {
|
||||
expect(2 + 2).toBe(4);
|
||||
await test.step('nested step', async () => {
|
||||
expect(2 + 2).toBe(4);
|
||||
await test.step('deeply nested step', async () => {
|
||||
expect(2 + 2).toBe(4);
|
||||
});
|
||||
})
|
||||
})
|
||||
});
|
||||
`
|
||||
});
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.report.suites.length).toBe(1);
|
||||
expect(result.report.suites[0].specs.length).toBe(1);
|
||||
// Ensure the length is as expected
|
||||
expect(result.report.suites[0].specs[0].tags.length).toBe(2);
|
||||
// Ensure that the '@' value is stripped
|
||||
expect(result.report.suites[0].specs[0].tags[0]).toBe('USR-MATH-001');
|
||||
expect(result.report.suites[0].specs[0].tags[1]).toBe('USR-MATH-002');
|
||||
});
|
||||
|
||||
test('should have relative always-posix paths', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user