testit-adapter-playwright 3.2.9 → 3.2.10-TMS-5.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/labels.d.ts CHANGED
@@ -19,7 +19,7 @@ interface AttachmentOptions {
19
19
  contentType: ContentType | string;
20
20
  fileExtension?: string;
21
21
  }
22
- declare enum ContentType {
22
+ export declare enum ContentType {
23
23
  TEXT = "text/plain",
24
24
  XML = "application/xml",
25
25
  HTML = "text/html",
@@ -33,7 +33,15 @@ declare enum ContentType {
33
33
  ZIP = "application/zip",
34
34
  WEBM = "video/webm",
35
35
  JPEG = "image/jpeg",
36
- MP4 = "video/mp4"
36
+ MP4 = "video/mp4",
37
+ MD = "text/markdown"
38
+ }
39
+ export declare enum Extensions {
40
+ PNG = ".png",
41
+ JPEG = ".jpg",
42
+ ZIP = ".zip",
43
+ WEBM = ".webm",
44
+ MD = ".md"
37
45
  }
38
46
  type Parameters = Record<string, string>;
39
47
  export declare class testit {
package/dist/labels.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.testit = void 0;
6
+ exports.testit = exports.Extensions = exports.ContentType = void 0;
7
7
  const crypto_1 = require("crypto");
8
8
  const test_1 = __importDefault(require("@playwright/test"));
9
9
  var ContentType;
@@ -22,7 +22,16 @@ var ContentType;
22
22
  ContentType["WEBM"] = "video/webm";
23
23
  ContentType["JPEG"] = "image/jpeg";
24
24
  ContentType["MP4"] = "video/mp4";
25
- })(ContentType || (ContentType = {}));
25
+ ContentType["MD"] = "text/markdown";
26
+ })(ContentType || (exports.ContentType = ContentType = {}));
27
+ var Extensions;
28
+ (function (Extensions) {
29
+ Extensions["PNG"] = ".png";
30
+ Extensions["JPEG"] = ".jpg";
31
+ Extensions["ZIP"] = ".zip";
32
+ Extensions["WEBM"] = ".webm";
33
+ Extensions["MD"] = ".md";
34
+ })(Extensions || (exports.Extensions = Extensions = {}));
26
35
  class testit {
27
36
  static async addMetadataAttachment(metadata) {
28
37
  await test_1.default.info().attach("tms-metadata.json", {
@@ -2,13 +2,27 @@ import { TestStatus } from "@playwright/test";
2
2
  import { TestError } from "@playwright/test/reporter";
3
3
  export interface Result {
4
4
  status: TestStatus;
5
- attachments: Array<{
6
- name: string;
7
- contentType: string;
8
- path?: string;
9
- body?: Buffer;
10
- }>;
5
+ attachments: Array<ResultAttachment>;
11
6
  duration: number;
12
7
  error?: TestError;
13
8
  errors: Array<TestError>;
14
9
  }
10
+ export interface ResultAttachment {
11
+ /**
12
+ * Attachment name.
13
+ */
14
+ name: string;
15
+ /**
16
+ * Content type of this attachment to properly present in the report, for example `'application/json'` or
17
+ * `'image/png'`.
18
+ */
19
+ contentType: string;
20
+ /**
21
+ * Optional path on the filesystem to the attached file.
22
+ */
23
+ path?: string;
24
+ /**
25
+ * Optional attachment body used instead of a file.
26
+ */
27
+ body?: Buffer;
28
+ }
@@ -10,7 +10,6 @@ export type ReporterOptions = {
10
10
  declare class TmsReporter implements Reporter {
11
11
  config: FullConfig;
12
12
  suite: Suite;
13
- resultsDir: string;
14
13
  options: ReporterOptions;
15
14
  strategy: IStrategy;
16
15
  private readonly additions;
@@ -23,6 +22,7 @@ declare class TmsReporter implements Reporter {
23
22
  onBegin(config: FullConfig, suite: Suite): void;
24
23
  onTestBegin(test: TestCase): void;
25
24
  onTestEnd(test: TestCase, result: TestResult): void;
25
+ private _processAttachmentsWithExtensions;
26
26
  onStepBegin(test: TestCase, _result: TestResult, step: TestStep): void;
27
27
  onEnd(): Promise<void>;
28
28
  addSkippedResults(): Promise<void>;
package/dist/reporter.js CHANGED
@@ -39,12 +39,16 @@ class TmsReporter {
39
39
  onTestEnd(test, result) {
40
40
  this.loadTestPromises.push(this.loadTest(test, {
41
41
  status: result.status,
42
- attachments: result.attachments,
42
+ attachments: this._processAttachmentsWithExtensions(result),
43
43
  duration: result.duration,
44
44
  errors: result.errors,
45
45
  error: result.error,
46
46
  }));
47
47
  }
48
+ // fix issues with trace and video files on playwright
49
+ _processAttachmentsWithExtensions(result) {
50
+ return result.attachments.map(utils_1.processAttachmentExtensions);
51
+ }
48
52
  onStepBegin(test, _result, step) {
49
53
  if (!this.testCache.includes(test)) {
50
54
  return;
@@ -94,7 +98,7 @@ class TmsReporter {
94
98
  for (const attachment of result.attachments) {
95
99
  if (!attachment.body) {
96
100
  if (attachment.path && attachment.name !== "screenshot") {
97
- const content = testit_js_commons_1.Utils.readBuffer(attachment.path);
101
+ const content = testit_js_commons_1.Utils.readBufferSync(attachment.path);
98
102
  await this.additions.addAttachments(content, attachment.name)
99
103
  .then((ids) => {
100
104
  autotestData.addAttachments?.push(...ids);
@@ -144,7 +148,8 @@ class TmsReporter {
144
148
  }
145
149
  if (attachment.name.match(utils_1.stepAttachRegexp)) {
146
150
  const step = this.attachmentStepsCache.find((step) => step.title === attachment.name);
147
- await this.additions.addAttachments(attachment.body, attachment.name.replace(utils_1.stepAttachRegexp, "")).then((ids) => {
151
+ await this.additions.addAttachments(attachment.body, attachment.name.replace(utils_1.stepAttachRegexp, ""))
152
+ .then((ids) => {
148
153
  if (step?.parent) {
149
154
  this.attachmentsMap.set(ids[0], step.parent);
150
155
  return;
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { TestError, TestStep } from "@playwright/test/reporter";
2
2
  import { Step } from "testit-js-commons";
3
+ import { ResultAttachment } from "./models/result";
3
4
  export type StatusDetails = {
4
5
  message?: string;
5
6
  trace?: string;
@@ -9,3 +10,4 @@ export declare function isAllStepsWithPassedOutcome(steps: Step[]): boolean;
9
10
  export declare function isStep(step: TestStep): boolean;
10
11
  export declare function stripAscii(str: string): string;
11
12
  export declare const stepAttachRegexp: RegExp;
13
+ export declare function processAttachmentExtensions(attachment: ResultAttachment): ResultAttachment;
package/dist/utils.js CHANGED
@@ -5,12 +5,15 @@ exports.getStatusDetails = getStatusDetails;
5
5
  exports.isAllStepsWithPassedOutcome = isAllStepsWithPassedOutcome;
6
6
  exports.isStep = isStep;
7
7
  exports.stripAscii = stripAscii;
8
+ exports.processAttachmentExtensions = processAttachmentExtensions;
8
9
  const converter_1 = require("./converter");
10
+ const labels_1 = require("./labels");
9
11
  function getStatusDetails(error) {
10
12
  const message = error.message && stripAscii(error.message);
11
13
  let trace = error.stack && stripAscii(error.stack);
12
14
  if (trace && message && trace.startsWith(`Error: ${message}`)) {
13
- trace = trace.substr(message.length + "Error: ".length);
15
+ const prefixLength = message.length + "Error: ".length;
16
+ trace = trace.substring(prefixLength);
14
17
  }
15
18
  return {
16
19
  message: message,
@@ -30,3 +33,34 @@ function stripAscii(str) {
30
33
  ;
31
34
  exports.stepAttachRegexp = /^stepattach_(\w{8}-\w{4}-\w{4}-\w{4}-\w{12})_/i;
32
35
  const asciiRegex = new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", "g");
36
+ function processAttachmentExtensions(attachment) {
37
+ switch (attachment.contentType) {
38
+ case labels_1.ContentType.ZIP:
39
+ if (!attachment.name.includes(labels_1.Extensions.ZIP)) {
40
+ attachment.name += labels_1.Extensions.ZIP;
41
+ }
42
+ return attachment;
43
+ case labels_1.ContentType.PNG:
44
+ if (!attachment.name.includes(labels_1.Extensions.PNG)) {
45
+ attachment.name += labels_1.Extensions.PNG;
46
+ }
47
+ return attachment;
48
+ case labels_1.ContentType.WEBM:
49
+ if (!attachment.name.includes(labels_1.Extensions.WEBM)) {
50
+ attachment.name += labels_1.Extensions.WEBM;
51
+ }
52
+ return attachment;
53
+ case labels_1.ContentType.MD:
54
+ if (!attachment.name.includes(labels_1.Extensions.MD)) {
55
+ attachment.name += labels_1.Extensions.MD;
56
+ }
57
+ return attachment;
58
+ case labels_1.ContentType.JPEG:
59
+ if (!attachment.name.includes(labels_1.Extensions.JPEG)) {
60
+ attachment.name += labels_1.Extensions.JPEG;
61
+ }
62
+ return attachment;
63
+ default:
64
+ return attachment;
65
+ }
66
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-adapter-playwright",
3
- "version": "3.2.9",
3
+ "version": "3.2.10-TMS-5.4",
4
4
  "description": "Playwright adapter for Test IT",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -40,7 +40,7 @@
40
40
  "prettier": "^3.0.1"
41
41
  },
42
42
  "dependencies": {
43
- "testit-js-commons": "3.2.9"
43
+ "testit-js-commons": "3.2.10-TMS-5.4"
44
44
  },
45
45
  "files": [
46
46
  "dist"