testit-adapter-cypress 3.7.6 → 3.7.8

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
@@ -1,5 +1,5 @@
1
1
  # Test IT TMS adapters for Cypress
2
- ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-js/master/images/banner.png)
2
+ ![Test IT](https://raw.githubusercontent.com/testit-tms/adapters-js/main/images/banner.png)
3
3
 
4
4
  ## Getting Started
5
5
 
@@ -158,14 +158,14 @@ describe('example to-do app', () => {
158
158
  tms.addDescription('Test description');
159
159
  tms.addLabels('label1', 'label2');
160
160
  tms.addTags('tag1', 'tag2');
161
- tms.addLinks([
161
+ tms.addLinks(
162
162
  {
163
163
  url: 'https://www.google.com',
164
164
  title: 'Google',
165
165
  description: 'This is a link to Google',
166
166
  type: 'Related',
167
167
  },
168
- ]);
168
+ );
169
169
  tms.addParameter("name", "value");
170
170
  tms.addNameSpace("namespace");
171
171
  tms.addClassName("classname");
@@ -1,30 +1,26 @@
1
- import { Label, Link, Status } from "testit-js-commons";
1
+ import { Link } from "testit-js-commons";
2
2
  import type { AttachmentOptions, TestRuntime } from "./types.js";
3
- import type { StatusDetails } from "../models/types.js";
4
3
  export declare const initTestRuntime: () => void;
5
4
  export declare const getTestRuntime: () => TmsCypressTestRuntime;
6
5
  declare class TmsCypressTestRuntime implements TestRuntime {
7
6
  #private;
8
7
  constructor();
9
- addLabels(...labels: Label[]): PromiseLike<void>;
8
+ addLabels(...labels: string[]): PromiseLike<void>;
10
9
  addTags(...tags: string[]): PromiseLike<void>;
11
10
  addLinks(...links: Link[]): PromiseLike<void>;
12
11
  addWorkItemIds(...workItemIds: string[]): PromiseLike<void>;
13
12
  addParameter(name: string, value: string): PromiseLike<void>;
14
- addDescription(markdown: string): PromiseLike<void>;
15
- addTitle(markdown: string): PromiseLike<void>;
16
- addDisplayName(name: string): PromiseLike<void>;
17
- addNameSpace(name: string): PromiseLike<void>;
18
- addClassName(name: string): PromiseLike<void>;
13
+ addDescription(description: string): PromiseLike<void>;
14
+ addTitle(title: string): PromiseLike<void>;
15
+ addDisplayName(displayName: string): PromiseLike<void>;
16
+ addNameSpace(namespace: string): PromiseLike<void>;
17
+ addClassName(classname: string): PromiseLike<void>;
19
18
  addAttachments(name: string, content: Buffer | string, options: AttachmentOptions): PromiseLike<void>;
20
19
  addAttachmentsFromPath(name: string, path: string, options: Omit<AttachmentOptions, "encoding">): PromiseLike<void>;
21
20
  addGlobalAttachments(name: string, content: Buffer | string, options: AttachmentOptions): PromiseLike<void>;
22
21
  addGlobalAttachmentsFromPath(name: string, path: string, options: Omit<AttachmentOptions, "encoding">): PromiseLike<void>;
23
- addMessage(details: StatusDetails): PromiseLike<void>;
24
- logStep(name: string, status?: Status, error?: Error): PromiseLike<void>;
22
+ addMessage(message: string): PromiseLike<void>;
25
23
  step<T = void>(name: string, body: () => T | PromiseLike<T>): Cypress.ThenReturn<T, T>;
26
- stepDisplayName(name: string): PromiseLike<void>;
27
- stepParameter(name: string, value: string): PromiseLike<void>;
28
24
  flushTmsMessagesToTask(taskName: string): void;
29
25
  flushTmsMessagesToTaskAsync(taskName: string): Cypress.Chainable<unknown> | undefined;
30
26
  }
@@ -4,10 +4,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var _TmsCypressTestRuntime_instances, _TmsCypressTestRuntime_resetMessages, _TmsCypressTestRuntime_enqueueMessageAsync, _TmsCypressTestRuntime_dequeueAllMessages, _TmsCypressTestRuntime_buildAttachmentContent, _TmsCypressTestRuntime_normalizeAttachmentContent, _TmsCypressTestRuntime_isSerializedBuffer, _TmsCypressTestRuntime_isInOriginContext;
7
+ var _TmsCypressTestRuntime_instances, _TmsCypressTestRuntime_resetMessages, _TmsCypressTestRuntime_enqueueMessageAsync, _TmsCypressTestRuntime_dequeueAllMessages, _TmsCypressTestRuntime_buildAttachmentContent, _TmsCypressTestRuntime_normalizeAttachmentContent, _TmsCypressTestRuntime_isSerializedBuffer;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getTestRuntime = exports.initTestRuntime = void 0;
10
- const testit_js_commons_1 = require("testit-js-commons");
11
10
  const state_js_1 = require("./state.js");
12
11
  const steps_js_1 = require("./steps.js");
13
12
  const utils_js_1 = require("./utils.js");
@@ -65,43 +64,43 @@ class TmsCypressTestRuntime {
65
64
  },
66
65
  });
67
66
  }
68
- addDescription(markdown) {
67
+ addDescription(description) {
69
68
  return __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_enqueueMessageAsync).call(this, {
70
69
  type: "metadata",
71
70
  data: {
72
- description: markdown,
71
+ description,
73
72
  },
74
73
  });
75
74
  }
76
- addTitle(markdown) {
75
+ addTitle(title) {
77
76
  return __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_enqueueMessageAsync).call(this, {
78
77
  type: "metadata",
79
78
  data: {
80
- title: markdown,
79
+ title,
81
80
  },
82
81
  });
83
82
  }
84
- addDisplayName(name) {
83
+ addDisplayName(displayName) {
85
84
  return __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_enqueueMessageAsync).call(this, {
86
85
  type: "metadata",
87
86
  data: {
88
- displayName: name,
87
+ displayName,
89
88
  },
90
89
  });
91
90
  }
92
- addNameSpace(name) {
91
+ addNameSpace(namespace) {
93
92
  return __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_enqueueMessageAsync).call(this, {
94
93
  type: "metadata",
95
94
  data: {
96
- namespace: name,
95
+ namespace,
97
96
  },
98
97
  });
99
98
  }
100
- addClassName(name) {
99
+ addClassName(classname) {
101
100
  return __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_enqueueMessageAsync).call(this, {
102
101
  type: "metadata",
103
102
  data: {
104
- classname: name,
103
+ classname,
105
104
  },
106
105
  });
107
106
  }
@@ -153,27 +152,12 @@ class TmsCypressTestRuntime {
153
152
  },
154
153
  });
155
154
  }
156
- addMessage(details) {
155
+ addMessage(message) {
157
156
  return __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_enqueueMessageAsync).call(this, {
158
- type: "global_error",
159
- data: details,
160
- });
161
- }
162
- logStep(name, status = testit_js_commons_1.Status.PASSED, error) {
163
- if (__classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_isInOriginContext).call(this)) {
164
- (0, steps_js_1.startTmsApiStep)(name);
165
- (0, steps_js_1.stopCurrentTmsApiStep)(status, error ? (0, utils_js_1.getMessageAndTraceFromError)(error) : undefined);
166
- return Cypress.Promise.resolve();
167
- }
168
- return cy
169
- .wrap(steps_js_1.TMS_STEP_CMD_SUBJECT, { log: false })
170
- .then(() => {
171
- (0, steps_js_1.startTmsApiStep)(name);
172
- return Cypress.Promise.resolve();
173
- })
174
- .then(() => {
175
- (0, steps_js_1.stopCurrentTmsApiStep)(status, error ? (0, utils_js_1.getMessageAndTraceFromError)(error) : undefined);
176
- return Cypress.Promise.resolve();
157
+ type: "metadata",
158
+ data: {
159
+ message,
160
+ },
177
161
  });
178
162
  }
179
163
  step(name, body) {
@@ -188,22 +172,6 @@ class TmsCypressTestRuntime {
188
172
  return result;
189
173
  });
190
174
  }
191
- stepDisplayName(name) {
192
- return __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_enqueueMessageAsync).call(this, {
193
- type: "step_metadata",
194
- data: {
195
- name,
196
- },
197
- });
198
- }
199
- stepParameter(name, value) {
200
- return __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_enqueueMessageAsync).call(this, {
201
- type: "step_metadata",
202
- data: {
203
- parameters: [{ name, value }],
204
- },
205
- });
206
- }
207
175
  flushTmsMessagesToTask(taskName) {
208
176
  const messages = __classPrivateFieldGet(this, _TmsCypressTestRuntime_instances, "m", _TmsCypressTestRuntime_dequeueAllMessages).call(this);
209
177
  if (messages.length) {
@@ -249,36 +217,4 @@ _TmsCypressTestRuntime_instances = new WeakSet(), _TmsCypressTestRuntime_resetMe
249
217
  }
250
218
  const candidate = content;
251
219
  return candidate.type === "Buffer" && Array.isArray(candidate.data);
252
- }, _TmsCypressTestRuntime_isInOriginContext = function _TmsCypressTestRuntime_isInOriginContext() {
253
- try {
254
- const hasOriginContext = !!window.cypressOriginContext;
255
- const hasOriginWindow = !!window.cypressOriginWindow;
256
- if (hasOriginContext || hasOriginWindow) {
257
- return true;
258
- }
259
- const baseUrl = Cypress.config("baseUrl");
260
- const currentOrigin = window.location.origin;
261
- if (baseUrl && currentOrigin !== baseUrl) {
262
- return true;
263
- }
264
- const cypressInstance = window.Cypress;
265
- if (cypressInstance && cypressInstance.state && cypressInstance.state("origin")) {
266
- return true;
267
- }
268
- try {
269
- const cyExists = typeof cy !== "undefined";
270
- const cyTaskExists = typeof cy.task !== "undefined";
271
- // In cy.origin context, cy.task may not be available or may throw
272
- if (!cyExists || !cyTaskExists) {
273
- return true;
274
- }
275
- }
276
- catch (error) {
277
- return true;
278
- }
279
- return false;
280
- }
281
- catch (error) {
282
- return true;
283
- }
284
220
  };
@@ -1,5 +1,4 @@
1
- import type { StatusDetails } from "../models/types.js";
2
- import { Label, Link, Status } from "testit-js-commons";
1
+ import { Link } from "testit-js-commons";
3
2
  export declare enum ContentType {
4
3
  PNG = "image/png",
5
4
  MP4 = "video/mp4",
@@ -14,8 +13,8 @@ export interface AttachmentOptions {
14
13
  body?: Buffer;
15
14
  }
16
15
  export interface TestRuntime {
17
- addLabels(...labels: Label[]): PromiseLike<void>;
18
- addTags(...tags: String[]): PromiseLike<void>;
16
+ addLabels(...labels: string[]): PromiseLike<void>;
17
+ addTags(...tags: string[]): PromiseLike<void>;
19
18
  addLinks(...links: Link[]): PromiseLike<void>;
20
19
  addWorkItemIds(...workItemIds: string[]): PromiseLike<void>;
21
20
  addParameter(name: string, value: string): PromiseLike<void>;
@@ -26,10 +25,7 @@ export interface TestRuntime {
26
25
  addAttachmentsFromPath(name: string, path: string, options: Omit<AttachmentOptions, "encoding">): PromiseLike<void>;
27
26
  addGlobalAttachments(name: string, content: Buffer | string, options: AttachmentOptions): PromiseLike<void>;
28
27
  addGlobalAttachmentsFromPath(name: string, path: string, options: Omit<AttachmentOptions, "encoding">): PromiseLike<void>;
29
- addMessage(details: StatusDetails): PromiseLike<void>;
30
- logStep(name: string, status?: Status, error?: Error): PromiseLike<void>;
28
+ addMessage(message: string): PromiseLike<void>;
31
29
  step<T>(name: string, body: () => T | PromiseLike<T>): PromiseLike<T>;
32
- stepDisplayName(name: string): PromiseLike<void>;
33
- stepParameter(name: string, value: string): PromiseLike<void>;
34
30
  }
35
31
  export declare const noopRuntime: TestRuntime;
@@ -23,8 +23,5 @@ exports.noopRuntime = {
23
23
  addGlobalAttachments: () => noop,
24
24
  addGlobalAttachmentsFromPath: () => noop,
25
25
  addMessage: () => noop,
26
- logStep: () => noop,
27
26
  step: (_, body) => Promise.resolve(body()),
28
- stepDisplayName: () => noop,
29
- stepParameter: () => noop,
30
27
  };
@@ -1,5 +1,6 @@
1
1
  import type { AutotestPost, AutotestResult, Outcome } from "testit-js-commons";
2
- import { Label, Link } from "testit-js-commons";
2
+ import { Link } from "testit-js-commons";
3
+ import { StatusDetails } from "./models/types";
3
4
  export interface StepData {
4
5
  id: string;
5
6
  name: string;
@@ -13,6 +14,7 @@ export interface StepData {
13
14
  };
14
15
  attachmentIds: string[];
15
16
  children: StepData[];
17
+ parameters?: Record<string, string>;
16
18
  }
17
19
  export interface TestData {
18
20
  fullNameSuffix: string;
@@ -21,7 +23,7 @@ export interface TestData {
21
23
  title?: string;
22
24
  namespace?: string;
23
25
  classname?: string;
24
- labels: Label[];
26
+ labels: string[];
25
27
  tags: string[];
26
28
  links: Link[];
27
29
  workItemIds: string[];
@@ -29,14 +31,11 @@ export interface TestData {
29
31
  stop?: number;
30
32
  outcome: Outcome;
31
33
  duration?: number;
32
- statusDetails?: {
33
- message?: string;
34
- trace?: string;
35
- };
34
+ statusDetails?: StatusDetails;
35
+ message?: string;
36
36
  steps: StepData[];
37
37
  attachmentIds: string[];
38
38
  parameters?: Record<string, string>;
39
- properties?: Record<string, string>;
40
39
  externalKey: string;
41
40
  }
42
41
  export declare function toAutotestPost(specPath: string, t: TestData): AutotestPost;
package/dist/converter.js CHANGED
@@ -20,6 +20,8 @@ function stepDataToStep(s) {
20
20
  step.duration = s.stop - s.start;
21
21
  if (s.statusDetails?.message)
22
22
  step.info = s.statusDetails.message;
23
+ if (s.parameters)
24
+ step.parameters = s.parameters;
23
25
  return step;
24
26
  }
25
27
  function stepDataToShortStep(s) {
@@ -32,7 +34,6 @@ function toAutotestPost(specPath, t) {
32
34
  const fullName = `${specPath}#${t.fullNameSuffix}`;
33
35
  const externalId = testit_js_commons_1.Utils.getHash(fullName);
34
36
  const name = (t.displayName ?? t.fullNameSuffix).replace(/#/g, " > ");
35
- const labels = t.labels?.map((l) => ({ name: l.name })) ?? [];
36
37
  return {
37
38
  externalId,
38
39
  name,
@@ -41,9 +42,9 @@ function toAutotestPost(specPath, t) {
41
42
  workItemIds: t.workItemIds,
42
43
  namespace: t.namespace,
43
44
  classname: t.classname,
44
- links: t.links?.length ? t.links : undefined,
45
- labels: labels.length ? labels : undefined,
46
- tags: t.tags?.length ? t.tags : undefined,
45
+ links: t.links?.length ? t.links : [],
46
+ labels: t.labels?.map((l) => ({ name: l })) ?? [],
47
+ tags: t.tags?.length ? t.tags : [],
47
48
  steps: t.steps.map(s => stepDataToShortStep(s)),
48
49
  externalKey: t.externalKey,
49
50
  };
@@ -73,12 +74,14 @@ function toAutotestResult(externalId, t, outcome, extraAttachmentIds = []) {
73
74
  if (t.parameters) {
74
75
  result.parameters = t.parameters;
75
76
  }
76
- if (t.properties) {
77
- result.properties = t.properties;
77
+ if (t.message) {
78
+ result.message = t.message;
78
79
  }
79
- if (t.statusDetails?.message)
80
+ else if (t.statusDetails?.message) {
80
81
  result.message = t.statusDetails.message;
81
- if (t.statusDetails?.trace)
82
+ }
83
+ if (t.statusDetails?.trace) {
82
84
  result.traces = t.statusDetails.trace;
85
+ }
83
86
  return result;
84
87
  }
@@ -106,7 +106,7 @@ export type CypressTestStartMessage = {
106
106
  name: string;
107
107
  fullNameSuffix: string;
108
108
  start: number;
109
- labels: Label[];
109
+ labels: string[];
110
110
  tags: string[];
111
111
  links: Link[];
112
112
  workItemIds: string[];
package/dist/reporter.js CHANGED
@@ -311,12 +311,11 @@ class TmsCypress {
311
311
  if (data.tags?.length) {
312
312
  current.tags.push(...data.tags);
313
313
  }
314
+ if (data.workItemIds?.length) {
315
+ current.workItemIds.push(...data.workItemIds);
316
+ }
314
317
  if (data.links?.length) {
315
- current.links.push(...data.links.map((l) => ({
316
- url: l.url,
317
- title: l.title ?? l.url,
318
- description: l.description,
319
- })));
318
+ current.links.push(...data.links);
320
319
  }
321
320
  if (data.parameters?.length) {
322
321
  current.parameters ?? (current.parameters = {});
@@ -327,15 +326,24 @@ class TmsCypress {
327
326
  if (data.description) {
328
327
  current.description = data.description;
329
328
  }
330
- else if (data.descriptionHtml && !current.description) {
331
- current.description = data.descriptionHtml;
332
- }
333
329
  if (data.displayName) {
334
330
  current.displayName = data.displayName;
335
331
  }
336
332
  if (data.title) {
337
333
  current.title = data.title;
338
334
  }
335
+ if (data.message) {
336
+ current.message = data.message;
337
+ }
338
+ if (data.details) {
339
+ current.statusDetails = data.details;
340
+ }
341
+ if (data.namespace) {
342
+ current.namespace = data.namespace;
343
+ }
344
+ if (data.classname) {
345
+ current.classname = data.classname;
346
+ }
339
347
  });
340
348
  const { videoOnFailOnly = false, ...rest } = config;
341
349
  this.videoOnFailOnly = videoOnFailOnly;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-adapter-cypress",
3
- "version": "3.7.6",
3
+ "version": "3.7.8",
4
4
  "description": "Cypress adapter for Test IT",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -42,7 +42,7 @@
42
42
  "@types/node": "^20.14.2"
43
43
  },
44
44
  "dependencies": {
45
- "testit-js-commons": "3.7.6"
45
+ "testit-js-commons": "3.7.8"
46
46
  },
47
47
  "files": [
48
48
  "dist"