fix(runner): mark tests skipped due to sharding in junit report (#7578)

This commit is contained in:
Yury Semikhatsky 2021-07-13 05:06:08 -07:00 committed by GitHub
parent 27d89732ce
commit 5d62d01450
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 0 deletions

View file

@ -34,6 +34,35 @@ test('should support spec.ok', async ({ runInlineTest }) => {
expect(result.report.suites[0].specs[1].ok).toBe(false); expect(result.report.suites[0].specs[1].ok).toBe(false);
}); });
test('should report skipped due to sharding', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.js': `
const { test } = pwt;
test('one', async () => {
});
test('two', async () => {
test.skip();
});
`,
'b.test.js': `
const { test } = pwt;
test('three', async () => {
});
test('four', async () => {
test.skip();
});
test('five', async () => {
});
`,
}, { shard: '1/3', reporter: 'json' });
expect(result.exitCode).toBe(0);
expect(result.report.suites[0].specs[0].tests[0].status).toBe('expected');
expect(result.report.suites[0].specs[1].tests[0].status).toBe('skipped');
expect(result.report.suites[1].specs[0].tests[0].status).toBe('skipped');
expect(result.report.suites[1].specs[1].tests[0].status).toBe('skipped');
expect(result.report.suites[1].specs[2].tests[0].status).toBe('skipped');
});
test('should report projects', async ({ runInlineTest }, testInfo) => { test('should report projects', async ({ runInlineTest }, testInfo) => {
const result = await runInlineTest({ const result = await runInlineTest({
'playwright.config.ts': ` 'playwright.config.ts': `

View file

@ -157,6 +157,39 @@ test('should render skipped', async ({ runInlineTest }) => {
expect(result.exitCode).toBe(0); expect(result.exitCode).toBe(0);
}); });
test('should report skipped due to sharding', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.js': `
const { test } = pwt;
test('one', async () => {
});
test('two', async () => {
test.skip();
});
`,
'b.test.js': `
const { test } = pwt;
test('three', async () => {
});
test('four', async () => {
test.skip();
});
test('five', async () => {
});
`,
}, { shard: '1/3', reporter: 'junit' });
const xml = parseXML(result.output);
expect(xml['testsuites']['testsuite'][0]['$']['tests']).toBe('2');
expect(xml['testsuites']['testsuite'][0]['$']['failures']).toBe('0');
expect(xml['testsuites']['testsuite'][0]['$']['skipped']).toBe('1');
expect(xml['testsuites']['testsuite'][1]['$']['tests']).toBe('3');
expect(xml['testsuites']['testsuite'][1]['$']['failures']).toBe('0');
expect(xml['testsuites']['testsuite'][1]['$']['skipped']).toBe('3');
expect(result.exitCode).toBe(0);
});
test('should render projects', async ({ runInlineTest }) => { test('should render projects', async ({ runInlineTest }) => {
const result = await runInlineTest({ const result = await runInlineTest({
'playwright.config.ts': ` 'playwright.config.ts': `