@testsmith/testblocks 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -177,7 +177,7 @@ program
177
177
  .argument('<patterns...>', 'Test file patterns (glob supported)')
178
178
  .option('-H, --headed', 'Run tests in headed mode (show browser)', false)
179
179
  .option('-t, --timeout <ms>', 'Test timeout in milliseconds', '30000')
180
- .option('-r, --reporter <type>', 'Reporter type: console, json, junit, html', 'console')
180
+ .option('-r, --reporter <types>', 'Reporter types (comma-separated): console, json, junit, html', 'console')
181
181
  .option('-o, --output <dir>', 'Output directory for reports', './testblocks-results')
182
182
  .option('-b, --base-url <url>', 'Base URL for relative URLs')
183
183
  .option('-v, --var <vars...>', 'Variables in key=value format')
@@ -275,8 +275,8 @@ program
275
275
  variables,
276
276
  procedures: globalProcedures,
277
277
  };
278
- // Create reporter
279
- const reporter = createReporter(options.reporter, options.output);
278
+ // Create reporters (supports multiple, comma-separated)
279
+ const reporters = createReporters(options.reporter, options.output);
280
280
  // Run tests
281
281
  const allResults = [];
282
282
  let hasFailures = false;
@@ -312,8 +312,8 @@ program
312
312
  const executor = new executor_1.TestExecutor(executorOptions);
313
313
  const results = await executor.runTestFile(testFile);
314
314
  allResults.push({ file, results });
315
- // Report results
316
- reporter.onTestFileComplete(file, testFile, results);
315
+ // Report results to all reporters
316
+ reporters.forEach(r => r.onTestFileComplete(file, testFile, results));
317
317
  // Check for failures
318
318
  const failed = results.some(r => r.status !== 'passed');
319
319
  if (failed) {
@@ -324,8 +324,8 @@ program
324
324
  }
325
325
  }
326
326
  }
327
- // Generate final report
328
- reporter.onComplete(allResults);
327
+ // Generate final reports
328
+ reporters.forEach(r => r.onComplete(allResults));
329
329
  // Exit with appropriate code
330
330
  process.exit(hasFailures ? 1 : 0);
331
331
  }
@@ -432,9 +432,10 @@ program
432
432
  'test:headed': 'testblocks run tests/**/*.testblocks.json --headed',
433
433
  'test:html': 'testblocks run tests/**/*.testblocks.json -r html -o reports',
434
434
  'test:junit': 'testblocks run tests/**/*.testblocks.json -r junit -o reports',
435
+ 'test:ci': 'testblocks run tests/**/*.testblocks.json -r console,html,junit -o reports',
435
436
  },
436
437
  devDependencies: {
437
- '@testsmith/testblocks': '^0.8.2',
438
+ '@testsmith/testblocks': '^0.8.4',
438
439
  },
439
440
  };
440
441
  fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2));
@@ -577,15 +578,31 @@ jobs:
577
578
  run: npx playwright install --with-deps chromium
578
579
 
579
580
  - name: Run tests
580
- run: npm test
581
+ run: npm run test:ci
581
582
 
582
- - name: Upload test reports
583
+ - name: Upload HTML report
583
584
  uses: actions/upload-artifact@v4
584
585
  if: always()
585
586
  with:
586
- name: test-reports
587
- path: reports/
587
+ name: html-report
588
+ path: reports/*.html
588
589
  retention-days: 30
590
+
591
+ - name: Upload JUnit report
592
+ uses: actions/upload-artifact@v4
593
+ if: always()
594
+ with:
595
+ name: junit-report
596
+ path: reports/*.xml
597
+ retention-days: 30
598
+
599
+ - name: Publish Test Results
600
+ uses: dorny/test-reporter@v1
601
+ if: always()
602
+ with:
603
+ name: Test Results
604
+ path: reports/*.xml
605
+ reporter: java-junit
589
606
  `;
590
607
  fs.writeFileSync(workflowPath, workflow);
591
608
  console.log(' Created: .github/workflows/testblocks.yml');
@@ -655,18 +672,35 @@ program
655
672
  open: options.open,
656
673
  });
657
674
  });
658
- function createReporter(type, outputDir) {
659
- switch (type) {
660
- case 'json':
661
- return new reporters_1.JSONReporter(outputDir);
662
- case 'junit':
663
- return new reporters_1.JUnitReporter(outputDir);
664
- case 'html':
665
- return new reporters_1.HTMLReporter(outputDir);
666
- case 'console':
667
- default:
668
- return new reporters_1.ConsoleReporter();
675
+ function createReporters(types, outputDir) {
676
+ const reporterTypes = types.split(',').map(t => t.trim().toLowerCase());
677
+ const reporters = [];
678
+ for (const type of reporterTypes) {
679
+ switch (type) {
680
+ case 'json':
681
+ reporters.push(new reporters_1.JSONReporter(outputDir));
682
+ break;
683
+ case 'junit':
684
+ reporters.push(new reporters_1.JUnitReporter(outputDir));
685
+ break;
686
+ case 'html':
687
+ reporters.push(new reporters_1.HTMLReporter(outputDir));
688
+ break;
689
+ case 'console':
690
+ reporters.push(new reporters_1.ConsoleReporter());
691
+ break;
692
+ default:
693
+ console.warn(`Unknown reporter type: ${type}, using console`);
694
+ if (!reporters.some(r => r instanceof reporters_1.ConsoleReporter)) {
695
+ reporters.push(new reporters_1.ConsoleReporter());
696
+ }
697
+ }
698
+ }
699
+ // Always include console reporter if not already included
700
+ if (!reporters.some(r => r instanceof reporters_1.ConsoleReporter)) {
701
+ reporters.unshift(new reporters_1.ConsoleReporter());
669
702
  }
703
+ return reporters;
670
704
  }
671
705
  function validateTestFile(testFile) {
672
706
  const errors = [];