playwright-ctrf-json-reporter 0.0.15 → 0.0.17

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/README.md CHANGED
@@ -12,27 +12,18 @@ A Playwright JSON test reporter to create test reports that follow the CTRF stan
12
12
 
13
13
  [Common Test Report Format](https://ctrf.io) ensures the generation of uniform JSON test reports, independent of programming languages or test framework in use.
14
14
 
15
- **If you find this project useful, consider giving it a GitHub star**
15
+ ## **⭐⭐ If you find this project useful, consider giving it a GitHub star ⭐⭐**
16
16
 
17
- It means a lot to us and helps us grow this open source library.
17
+ ## Help us get featured on the Playwright Reporter showcase
18
18
 
19
- ## We need your help
19
+ We'd love to be featured but we need more followers and stars to be [considered](https://github.com/microsoft/playwright/pull/31470)
20
20
 
21
- We believe CTRF can save **a lot** of time for engineers, a single data serialisation report, well structured, community driven and works with any framework. For over 30s years software engineers have used a de facto data serialisation report, you know the one! But we feel it’s time to modernise.
21
+ Support our mission to enhance JSON test reporting by:
22
22
 
23
- The only way we can grow CTRF is with your help and the support of the software engineering community.
23
+ - **⭐ Starring this repository to show your support. ⭐**
24
+ - **🙌 Following our [GitHub page here](https://github.com/ctrf-io). 🙌**
24
25
 
25
- ## How can you help?
26
-
27
- - Join and build with us! We are looking for [contributors](https://github.com/ctrf-io), get involved in this early stage project. All contributions are welcome.
28
- - Give this repository a star ⭐⭐⭐⭐⭐⭐
29
- - Follow the CTRF [GitHub organisation](https://github.com/ctrf-io)
30
- - Clap for our medium articles (30 times each) 👏
31
- - Share our [libraries](https://github.com/orgs/ctrf-io/repositories), our [homepage](https://www.ctrf.io/), or [Medium articles](https://medium.com/@ma11hewthomas)
32
- - Maybe even write a blog about us!
33
- - Try our [tools](https://github.com/orgs/ctrf-io/repositories)
34
-
35
- **Thank you so much!!**
26
+ Thank you! Your support is invaluable to us! 💙
36
27
 
37
28
  ## Features
38
29
 
@@ -162,6 +153,7 @@ The test object in the report includes the following [CTRF properties](https://c
162
153
  | `flaky` | Boolean | Optional | Indicates whether the test result is flaky. |
163
154
  | `browser` | String | Optional | The browser used for the test. |
164
155
  | `screenshot` | String | Optional | A base64 encoded screenshot taken during the test. |
156
+ | `steps` | Array of Objects | Optional | Individual steps in the test, especially for BDD-style testing. |
165
157
 
166
158
  ## Advanced usage
167
159
 
@@ -1,4 +1,4 @@
1
- import { type Suite, type Reporter, type TestCase, type TestResult, type FullConfig } from '@playwright/test/reporter';
1
+ import { type Suite, type Reporter, type TestCase, type TestResult, type FullConfig, type TestStep } from '@playwright/test/reporter';
2
2
  import { type CtrfTestState, type CtrfReport, type CtrfTest, type CtrfEnvironment } from '../types/ctrf';
3
3
  interface ReporterConfigOptions {
4
4
  outputFile?: string;
@@ -48,5 +48,6 @@ declare class GenerateCtrfReport implements Reporter {
48
48
  extractFailureDetails(testResult: TestResult): Partial<CtrfTest>;
49
49
  countSuites(suite: Suite): number;
50
50
  writeReportToFile(data: CtrfReport): void;
51
+ processStep(test: CtrfTest, step: TestStep): void;
51
52
  }
52
53
  export default GenerateCtrfReport;
@@ -118,6 +118,12 @@ class GenerateCtrfReport {
118
118
  test.filePath = testCase.location.file;
119
119
  test.retries = testResult.retry;
120
120
  test.flaky = testResult.status === 'passed' && testResult.retry > 0;
121
+ test.steps = [];
122
+ if (testResult.steps.length > 0) {
123
+ testResult.steps.forEach((step) => {
124
+ this.processStep(test, step);
125
+ });
126
+ }
121
127
  if (this.reporterConfigOptions.screenshot === true) {
122
128
  test.screenshot = this.extractScreenshotBase64(testResult);
123
129
  }
@@ -249,7 +255,10 @@ class GenerateCtrfReport {
249
255
  return (_a = screenshotAttachment === null || screenshotAttachment === void 0 ? void 0 : screenshotAttachment.body) === null || _a === void 0 ? void 0 : _a.toString('base64');
250
256
  }
251
257
  extractFailureDetails(testResult) {
252
- if (testResult.status === 'failed' && testResult.error !== undefined) {
258
+ if ((testResult.status === 'failed' ||
259
+ testResult.status === 'timedOut' ||
260
+ testResult.status === 'interrupted') &&
261
+ testResult.error !== undefined) {
253
262
  const failureDetails = {};
254
263
  if (testResult.error.message !== undefined) {
255
264
  failureDetails.message = testResult.error.message;
@@ -280,5 +289,24 @@ class GenerateCtrfReport {
280
289
  console.error(`Error writing ctrf json report:, ${String(error)}`);
281
290
  }
282
291
  }
292
+ processStep(test, step) {
293
+ var _a;
294
+ if (step.category === 'test.step') {
295
+ const stepStatus = step.error === undefined
296
+ ? this.mapPlaywrightStatusToCtrf('passed')
297
+ : this.mapPlaywrightStatusToCtrf('failed');
298
+ const currentStep = {
299
+ name: step.title,
300
+ status: stepStatus,
301
+ };
302
+ (_a = test.steps) === null || _a === void 0 ? void 0 : _a.push(currentStep);
303
+ }
304
+ const childSteps = step.steps;
305
+ if (childSteps.length > 0) {
306
+ childSteps.forEach((cStep) => {
307
+ this.processStep(test, cStep);
308
+ });
309
+ }
310
+ }
283
311
  }
284
312
  exports.default = GenerateCtrfReport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright-ctrf-json-reporter",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "A Playwright JSON test reporter to create test results reports",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {