From d42c4996a437ffeb4ba8fab20ddd8c8c99d1192c Mon Sep 17 00:00:00 2001 From: Mathias Leppich Date: Mon, 27 May 2024 15:50:26 +0200 Subject: [PATCH] revert json/junit test changes --- tests/playwright-test/reporter-json.spec.ts | 41 +++++------------ tests/playwright-test/reporter-junit.spec.ts | 47 ++++++-------------- 2 files changed, 25 insertions(+), 63 deletions(-) diff --git a/tests/playwright-test/reporter-json.spec.ts b/tests/playwright-test/reporter-json.spec.ts index 43bec5b7f5..f8ec8b9b0b 100644 --- a/tests/playwright-test/reporter-json.spec.ts +++ b/tests/playwright-test/reporter-json.spec.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import * as fs from 'fs'; import * as path from 'path'; -import { expect, stripAnsi, test } from './playwright-test-fixtures'; +import * as fs from 'fs'; +import { test, expect, stripAnsi } from './playwright-test-fixtures'; test('should support spec.ok and stats', async ({ runInlineTest }) => { const result = await runInlineTest({ @@ -31,7 +31,7 @@ test('should support spec.ok and stats', async ({ runInlineTest }) => { test.skip('math skipped', async ({}) => { }); ` - }, {}); + }, { }); expect(result.exitCode).toBe(1); expect(result.report.suites[0].specs[0].ok).toBe(true); expect(result.report.suites[0].specs[1].ok).toBe(false); @@ -43,7 +43,7 @@ test('should support spec.ok and stats', async ({ runInlineTest }) => { }); test('should not report skipped due to sharding', async ({ runInlineTest }) => { - const tests = { + const result = await runInlineTest({ 'a.test.js': ` import { test, expect } from '@playwright/test'; test('one', async () => { @@ -62,29 +62,12 @@ test('should not report skipped due to sharding', async ({ runInlineTest }) => { test('five', async () => { }); `, - }; - { - const result = await runInlineTest(tests, { shard: '1/3', reporter: 'json' }); - expect(result.exitCode).toBe(0); - expect(result.report.suites.length).toBe(1); - expect(result.report.suites[0].specs.length).toBe(3); - 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[0].specs[2].tests[0].status).toBe('expected'); - } - { - const result = await runInlineTest(tests, { shard: '2/3', reporter: 'json' }); - expect(result.exitCode).toBe(0); - expect(result.report.suites.length).toBe(1); - expect(result.report.suites[0].specs.length).toBe(2); - expect(result.report.suites[0].specs[0].tests[0].status).toBe('expected'); - expect(result.report.suites[0].specs[1].tests[0].status).toBe('skipped'); - } - { - const result = await runInlineTest(tests, { shard: '3/3', reporter: 'json' }); - expect(result.exitCode).toBe(0); - expect(result.report.suites.length).toBe(0); - } + }, { shard: '1/3', reporter: 'json' }); + expect(result.exitCode).toBe(0); + expect(result.report.suites.length).toBe(1); + expect(result.report.suites[0].specs.length).toBe(2); + expect(result.report.suites[0].specs[0].tests[0].status).toBe('expected'); + expect(result.report.suites[0].specs[1].tests[0].status).toBe('skipped'); }); test('should report projects and stats', async ({ runInlineTest }, testInfo) => { @@ -112,7 +95,7 @@ test('should report projects and stats', async ({ runInlineTest }, testInfo) => expect(1 + 1).toBe(2); }); ` - }, {}); + }, { }); expect(result.exitCode).toBe(0); const projects = result.report.config.projects; const testDir = testInfo.outputDir.split(path.sep).join(path.posix.sep); @@ -262,7 +245,7 @@ test('should have starting time in results', async ({ runInlineTest }, testInfo) expect(1 + 1).toBe(2); }); ` - }, { reporter: 'json' }); + }, { reporter: 'json' }); expect(result.exitCode).toBe(0); const startTime = result.report.suites[0].specs[0].tests[0].results[0].startTime; expect(new Date(startTime).getTime()).toBeGreaterThan(new Date('1/1/2000').getTime()); diff --git a/tests/playwright-test/reporter-junit.spec.ts b/tests/playwright-test/reporter-junit.spec.ts index b15106fc0f..6db49cbba0 100644 --- a/tests/playwright-test/reporter-junit.spec.ts +++ b/tests/playwright-test/reporter-junit.spec.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import fs from 'fs'; -import path from 'path'; import xml2js from 'xml2js'; -import { expect, test } from './playwright-test-fixtures'; +import path from 'path'; +import { test, expect } from './playwright-test-fixtures'; +import fs from 'fs'; for (const useIntermediateMergeReport of [false, true] as const) { test.describe(`${useIntermediateMergeReport ? 'merged' : 'created'}`, () => { @@ -190,8 +190,8 @@ for (const useIntermediateMergeReport of [false, true] as const) { expect(result.exitCode).toBe(0); }); - test('should not report skipped due to sharding', async ({ runInlineTest }) => { - const tests = { + test('should report skipped due to sharding', async ({ runInlineTest }) => { + const result = await runInlineTest({ 'a.test.js': ` import { test, expect } from '@playwright/test'; test('one', async () => { @@ -210,34 +210,13 @@ for (const useIntermediateMergeReport of [false, true] as const) { test('five', async () => { }); `, - }; - { - const result = await runInlineTest(tests, { shard: '1/3', reporter: 'junit' }); - const xml = parseXML(result.output); - expect(xml['testsuites']['testsuite'].length).toBe(1); - expect(xml['testsuites']['testsuite'][0]['$']['tests']).toBe('3'); - expect(xml['testsuites']['testsuite'][0]['$']['failures']).toBe('0'); - expect(xml['testsuites']['testsuite'][0]['$']['skipped']).toBe('1'); - expect(result.exitCode).toBe(0); - } - { - const result = await runInlineTest(tests, { shard: '2/3', reporter: 'junit' }); - const xml = parseXML(result.output); - expect(xml['testsuites']['testsuite'].length).toBe(1); - 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(result.exitCode).toBe(0); - } - { - const result = await runInlineTest(tests, { shard: '3/3', reporter: 'junit' }); - const xml = parseXML(result.output); - expect(xml['testsuites']['testsuite']).toBe(undefined); - expect(xml['testsuites']['$']['tests']).toBe('0'); - expect(xml['testsuites']['$']['failures']).toBe('0'); - expect(xml['testsuites']['$']['skipped']).toBe('0'); - expect(result.exitCode).toBe(0); - } + }, { shard: '1/3', reporter: 'junit' }); + const xml = parseXML(result.output); + expect(xml['testsuites']['testsuite'].length).toBe(1); + 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(result.exitCode).toBe(0); }); test('should not render projects if they dont exist', async ({ runInlineTest }) => { @@ -581,4 +560,4 @@ for (const useIntermediateMergeReport of [false, true] as const) { expect(time).toBeGreaterThan(1); }); }); -} +} \ No newline at end of file