playwright-ai-reporter 0.0.4 → 0.0.5

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.
@@ -1,4 +1,4 @@
1
- import { Reporter, TestCase, TestResult, FullConfig, Suite } from '@playwright/test/reporter';
1
+ import { Reporter, TestCase, TestResult, FullConfig, Suite, TestStep, FullResult } from '@playwright/test/reporter';
2
2
  import { ReporterConfig } from './types';
3
3
  /**
4
4
  * PlaywrightTestReporter is a modern, maintainable reporter for Playwright tests.
@@ -62,12 +62,34 @@ export default class PlaywrightTestReporter implements Reporter {
62
62
  * @param result - The result of the test execution
63
63
  */
64
64
  onTestEnd(test: TestCase, result: TestResult): void;
65
+ /**
66
+ * Called when a test begins.
67
+ *
68
+ * @param test - The test case that is starting
69
+ */
70
+ onTestBegin(test: TestCase, result: TestResult): Promise<void>;
71
+ /**
72
+ * Called when a test step begins.
73
+ *
74
+ * @param test - The test case
75
+ * @param result - The current test result
76
+ * @param step - The test step that is starting
77
+ */
78
+ onStepBegin(test: TestCase, result: TestResult, step: TestStep): Promise<void>;
79
+ /**
80
+ * Called when a test step ends.
81
+ *
82
+ * @param test - The test case
83
+ * @param result - The current test result
84
+ * @param step - The test step that ended
85
+ */
86
+ onStepEnd(test: TestCase, result: TestResult, step: TestStep): Promise<void>;
65
87
  /**
66
88
  * Called when all tests have completed.
67
89
  * Processes results, displays summary statistics, and sets appropriate exit code.
68
90
  * Now properly handles all error conditions including non-test errors.
69
91
  */
70
- onEnd(): Promise<void>;
92
+ onEnd(result: FullResult): Promise<void>;
71
93
  /**
72
94
  * Exits the process with a success code.
73
95
  * Extracted to a method to make the flow clearer and more maintainable.
@@ -80,6 +102,14 @@ export default class PlaywrightTestReporter implements Reporter {
80
102
  * @private
81
103
  */
82
104
  private _exitWithError;
105
+ /**
106
+ * Helper method to log messages with appropriate coloring.
107
+ *
108
+ * @param level - The log level ('debug' or 'error')
109
+ * @param message - The message to log
110
+ * @private
111
+ */
112
+ private _log;
83
113
  /**
84
114
  * Formats and logs the outcome of a single test with appropriate coloring.
85
115
  * Handles different test states (passed, failed, skipped) and retry attempts.
package/dist/reporter.js CHANGED
@@ -171,6 +171,7 @@ class PlaywrightTestReporter {
171
171
  onTestEnd(test, result) {
172
172
  const title = test.title;
173
173
  const timeTakenSec = result.duration / 1000;
174
+ console.log(`${colors_1.colors.fgCyan}Finished test: ${colors_1.colors.fgMagentaBright}${test.title}${colors_1.colors.fgCyan}: ${result.status}${colors_1.colors.reset}`);
174
175
  // Initialize test record if first attempt
175
176
  if (!this._testRecords.has(title)) {
176
177
  // Create an enhanced test case with required properties
@@ -227,12 +228,57 @@ class PlaywrightTestReporter {
227
228
  // Log test outcome with appropriate formatting
228
229
  this._logTestOutcome(test.title, result, timeTakenSec);
229
230
  }
231
+ /**
232
+ * Called when a test begins.
233
+ *
234
+ * @param test - The test case that is starting
235
+ */
236
+ async onTestBegin(test, result) {
237
+ if (result.retry > 0) {
238
+ console.log(`${colors_1.colors.fgYellow}🔄 Retrying test (attempt #${result.retry + 1}): ${colors_1.colors.fgMagentaBright}${test.title}${colors_1.colors.reset}`);
239
+ }
240
+ else {
241
+ console.log(`${colors_1.colors.fgCyan}Starting test: ${colors_1.colors.fgMagentaBright}${test.title}${colors_1.colors.reset}`);
242
+ }
243
+ }
244
+ /**
245
+ * Called when a test step begins.
246
+ *
247
+ * @param test - The test case
248
+ * @param result - The current test result
249
+ * @param step - The test step that is starting
250
+ */
251
+ async onStepBegin(test, result, step) {
252
+ if (step.category !== 'test.step')
253
+ return;
254
+ this._log('debug', `Test step BEGIN: ${step.title}`);
255
+ }
256
+ /**
257
+ * Called when a test step ends.
258
+ *
259
+ * @param test - The test case
260
+ * @param result - The current test result
261
+ * @param step - The test step that ended
262
+ */
263
+ async onStepEnd(test, result, step) {
264
+ if (step.category !== 'test.step')
265
+ return;
266
+ if (step.error) {
267
+ this._log('error', `Test step FAILED: ${step.title}`);
268
+ }
269
+ else {
270
+ this._log('debug', `Test step END: ${step.title}`);
271
+ }
272
+ }
230
273
  /**
231
274
  * Called when all tests have completed.
232
275
  * Processes results, displays summary statistics, and sets appropriate exit code.
233
276
  * Now properly handles all error conditions including non-test errors.
234
277
  */
235
- async onEnd() {
278
+ async onEnd(result) {
279
+ console.log(`${colors_1.colors.fgCyan}===============================================${colors_1.colors.reset}`);
280
+ console.log(`${colors_1.colors.fgMagentaBright}Finished the test run: ${result.status.toUpperCase()}${colors_1.colors.reset}`);
281
+ console.log(`${colors_1.colors.fgCyan}===============================================${colors_1.colors.reset}`);
236
282
  const endTime = Date.now();
237
283
  const totalTimeSec = (endTime - this._startTime) / 1000;
238
284
  const totalTimeDisplay = utils_1.TestUtils.formatTime(totalTimeSec);
@@ -326,6 +372,21 @@ class PlaywrightTestReporter {
326
372
  _exitWithError() {
327
373
  process.exitCode = 1;
328
374
  }
375
+ /**
376
+ * Helper method to log messages with appropriate coloring.
377
+ *
378
+ * @param level - The log level ('debug' or 'error')
379
+ * @param message - The message to log
380
+ * @private
381
+ */
382
+ _log(level, message) {
383
+ if (level === 'error') {
384
+ console.log(`${colors_1.colors.fgRed}${message}${colors_1.colors.reset}`);
385
+ }
386
+ else {
387
+ console.log(`${colors_1.colors.fgGray}${message}${colors_1.colors.reset}`);
388
+ }
389
+ }
329
390
  /**
330
391
  * Formats and logs the outcome of a single test with appropriate coloring.
331
392
  * Handles different test states (passed, failed, skipped) and retry attempts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright-ai-reporter",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Enterprise-grade AI-powered test reporter for Playwright with automatic bug creation, intelligent fix suggestions, auto-healing PRs, and multi-provider support for CI/CD pipelines.",
5
5
  "keywords": [
6
6
  "playwright",
Binary file
Binary file