@@ -243,22 +243,43 @@ jobs:
243243 deleted: []
244244 };
245245
246+ // Helper function to extract all tests from a suite recursively
247+ function extractTestsFromSuite(suite, parentTitle = '') {
248+ let tests = [];
249+ const fullSuiteTitle = parentTitle ? `${parentTitle} > ${suite.title}` : suite.title;
250+
251+ // Add tests from specs
252+ if (suite.specs) {
253+ tests.push(...suite.specs.map(spec => ({
254+ title: `${fullSuiteTitle} > ${spec.title}`,
255+ status: spec.ok ? 'passed' : spec.skipped ? 'skipped' : 'failed',
256+ file: suite.file
257+ })));
258+ }
259+
260+ // Recursively process nested suites
261+ if (suite.suites) {
262+ suite.suites.forEach(nestedSuite => {
263+ tests.push(...extractTestsFromSuite(nestedSuite, fullSuiteTitle));
264+ });
265+ }
266+
267+ return tests;
268+ }
269+
246270 // Read current PR test results
247271 if (fs.existsSync(testResultsPath)) {
248272 const rawData = fs.readFileSync(testResultsPath);
249273 const data = JSON.parse(rawData);
274+ const allTests = data.suites.flatMap(suite => extractTestsFromSuite(suite));
275+
250276 testResults = {
251277 total: data.stats.expected + data.stats.unexpected + data.stats.flaky + data.stats.skipped,
252278 passed: data.stats.expected,
253279 failed: data.stats.unexpected,
254280 flaky: data.stats.flaky,
255281 skipped: data.stats.skipped,
256- tests: data.suites.flatMap(suite =>
257- suite.specs.map(spec => ({
258- title: `${suite.title} ${spec.title}`,
259- status: spec.ok ? 'passed' : spec.skipped ? 'skipped' : 'failed'
260- }))
261- )
282+ tests: allTests
262283 };
263284 } else {
264285 console.log('Test results file not found');
@@ -269,40 +290,34 @@ jobs:
269290 if (fs.existsSync(mainTestResultsPath)) {
270291 const rawData = fs.readFileSync(mainTestResultsPath);
271292 const data = JSON.parse(rawData);
272- mainTestResults = {
273- tests: data.suites.flatMap(suite =>
274- suite.specs.map(spec => ({
275- title: `${suite.title} ${spec.title}`,
276- status: spec.ok ? 'passed' : spec.skipped ? 'skipped' : 'failed'
277- }))
278- )
279- };
293+ const allTests = data.suites.flatMap(suite => extractTestsFromSuite(suite));
294+ mainTestResults = { tests: allTests };
280295
281296 // Compare tests
282- const currentTests = new Set (testResults.tests.map(t => t.title));
283- const mainTests = new Set (mainTestResults.tests.map(t => t.title));
297+ const currentTests = new Map (testResults.tests.map(t => [ t.title, t] ));
298+ const mainTests = new Map (mainTestResults.tests.map(t => [ t.title, t] ));
284299
285300 // Find new tests
286- testResults.tests.forEach( test => {
287- if (!mainTests.has(test. title)) {
288- testComparison.new.push(test.title);
301+ for (const [title, test] of currentTests) {
302+ if (!mainTests.has(title)) {
303+ testComparison.new.push(`${ test.file}: ${ title}` );
289304 }
290- });
305+ }
291306
292307 // Find deleted tests
293- mainTestResults.tests.forEach( test => {
294- if (!currentTests.has(test. title)) {
295- testComparison.deleted.push(test.title);
308+ for (const [title, test] of mainTests) {
309+ if (!currentTests.has(title)) {
310+ testComparison.deleted.push(`${ test.file}: ${ title}` );
296311 }
297- });
312+ }
298313
299314 // Find newly skipped tests
300- testResults.tests.forEach( test => {
301- const mainTest = mainTestResults.tests.find(t => t.title === test. title);
315+ for (const [title, test] of currentTests) {
316+ const mainTest = mainTests.get( title);
302317 if (mainTest && mainTest.status !== 'skipped' && test.status === 'skipped') {
303- testComparison.skipped.push(test.title);
318+ testComparison.skipped.push(`${ test.file}: ${ title}` );
304319 }
305- });
320+ }
306321 } else {
307322 console.log('Main branch test results file not found');
308323 mainTestResults = { tests: [] };
0 commit comments