testit-adapter-jest 5.0.5 → 5.0.7

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
@@ -123,12 +123,14 @@ $ npx jest -t "$(cat tmp/filter.txt)"
123
123
  Methods can be used to specify information about autotest.
124
124
 
125
125
  Description of metadata methods:
126
- - `testit.workItemIds` - a method that links autotests with manual tests. Receives the array of manual tests' IDs
126
+ - `testit.workItemId` - a method that links an autotest with a manual test. Receives a single globalId
127
+ - `testit.workItemIds` - deprecated, use `testit.workItemId` instead
127
128
  - `testit.displayName` - internal autotest name (used in Test IT)
128
129
  - `testit.externalId` - unique internal autotest ID (used in Test IT)
129
130
  - `testit.title` - autotest name specified in the autotest card. If not specified, the name from the displayName method is used
130
131
  - `testit.description` - autotest description specified in the autotest card
131
132
  - `testit.labels` - labels listed in the autotest card
133
+ - `testit.layer` - test pyramid layer in the autotest card (source **Run**). Use `TestLayers` from `testit-js-commons` for recommended values (`E2E`, `UI`, `API`, `Contract`, `Integration`, `Component`, `Unit`), or any custom string
132
134
  - `testit.tags` - tags listed in the autotest card
133
135
  - `testit.link` - links listed in the autotest card
134
136
  - `testit.namespace` - directory in the TMS system (default - directory's name of test)
@@ -144,12 +146,15 @@ Description of methods:
144
146
 
145
147
  #### Simple test
146
148
  ```js
149
+ import { TestLayers } from 'testit-js-commons';
150
+
147
151
  test('All annotations', () => {
148
152
  testit.externalId('all_annotations');
149
153
  testit.displayName('All annotations');
150
154
  testit.title('All annotations title');
151
155
  testit.description('Test with all annotations');
152
156
  testit.labels(['label1', 'label2']);
157
+ testit.layer(TestLayers.API);
153
158
 
154
159
  testit.addMessage('This is a message');
155
160
  testit.addLinks([
@@ -47,6 +47,7 @@ export default class TestItEnvironment extends NodeEnvironment {
47
47
  private snapshotAutotestData;
48
48
  private buildSetupSteps;
49
49
  private buildTeardownSteps;
50
+ private buildAutotestPost;
50
51
  private sendRealtimePayload;
51
52
  /** afterAll hooks run after all tests; patch teardown when importRealtime is enabled. */
52
53
  private flushRealtimeTeardown;
@@ -61,7 +62,12 @@ export default class TestItEnvironment extends NodeEnvironment {
61
62
  addAttachments(attachments: string[]): void;
62
63
  setLinks(links: Link[]): void;
63
64
  setLabels(labels: string[]): void;
65
+ setLayer(layer: string): void;
64
66
  setTags(tags: string[]): void;
67
+ setWorkItemId(globalId: string): void;
68
+ /**
69
+ * @deprecated Use workItemId with a single globalId instead.
70
+ */
65
71
  setWorkItems(workItems: string[]): void;
66
72
  setParams(params: any): void;
67
73
  setNameSpace(nameSpace: string): void;
@@ -94,7 +94,9 @@ class TestItEnvironment extends jest_environment_node_1.default {
94
94
  displayName: this.setDisplayName.bind(this),
95
95
  links: this.setLinks.bind(this),
96
96
  labels: this.setLabels.bind(this),
97
+ layer: this.setLayer.bind(this),
97
98
  tags: this.setTags.bind(this),
99
+ workItemId: this.setWorkItemId.bind(this),
98
100
  workItemIds: this.setWorkItems.bind(this),
99
101
  params: this.setParams.bind(this),
100
102
  step: this.startStep.bind(this),
@@ -286,24 +288,15 @@ class TestItEnvironment extends jest_environment_node_1.default {
286
288
  const afterEach = autotest.afterEach;
287
289
  return includeAfterAll ? afterEach.concat(this.afterAllSteps) : afterEach;
288
290
  }
289
- async sendRealtimePayload(autotest, result, includeAfterAll) {
290
- const setupSteps = this.buildSetupSteps(autotest);
291
- const teardownSteps = this.buildTeardownSteps(autotest, includeAfterAll);
292
- testit_js_commons_2.logger.debug("[jest-env] sendRealtimePayload", {
293
- externalId: autotest.externalId,
294
- outcome: result.outcome,
295
- includeAfterAll,
296
- setupSteps: setupSteps.length,
297
- teardownSteps: teardownSteps.length,
298
- testSteps: autotest.testSteps.length,
299
- });
300
- const autotestPost = {
291
+ buildAutotestPost(autotest, setupSteps, teardownSteps) {
292
+ return {
301
293
  externalId: autotest.externalId,
302
294
  title: autotest.title,
303
295
  name: autotest.name,
304
296
  description: autotest.description,
305
297
  links: autotest.links,
306
298
  labels: autotest.labels,
299
+ layer: autotest.layer,
307
300
  tags: autotest.tags,
308
301
  namespace: autotest.namespace ?? testit_js_commons_1.Utils.getDir(this.testPath),
309
302
  classname: autotest.classname ?? testit_js_commons_1.Utils.getFileName(this.testPath),
@@ -311,7 +304,21 @@ class TestItEnvironment extends jest_environment_node_1.default {
311
304
  steps: autotest.testSteps,
312
305
  teardown: teardownSteps,
313
306
  externalKey: autotest.externalKey,
307
+ workItemIds: autotest.workItemIds,
314
308
  };
309
+ }
310
+ async sendRealtimePayload(autotest, result, includeAfterAll) {
311
+ const setupSteps = this.buildSetupSteps(autotest);
312
+ const teardownSteps = this.buildTeardownSteps(autotest, includeAfterAll);
313
+ testit_js_commons_2.logger.debug("[jest-env] sendRealtimePayload", {
314
+ externalId: autotest.externalId,
315
+ outcome: result.outcome,
316
+ includeAfterAll,
317
+ setupSteps: setupSteps.length,
318
+ teardownSteps: teardownSteps.length,
319
+ testSteps: autotest.testSteps.length,
320
+ });
321
+ const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
315
322
  await this.strategy.loadAutotest(autotestPost, result.outcome);
316
323
  await this.strategy.loadTestRun([
317
324
  {
@@ -351,6 +358,8 @@ class TestItEnvironment extends jest_environment_node_1.default {
351
358
  if (setupSteps.length === 0 && teardownSteps.length === 0) {
352
359
  continue;
353
360
  }
361
+ const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
362
+ await this.strategy.loadAutotest(autotestPost, result.outcome);
354
363
  await this.strategy.updateSetupTeardown([
355
364
  {
356
365
  autoTestExternalId: autotest.externalId,
@@ -380,21 +389,7 @@ class TestItEnvironment extends jest_environment_node_1.default {
380
389
  log("Mapping autotest %s", autotest.name);
381
390
  const setupSteps = this.beforeAllSteps.concat(autotest.beforeEach);
382
391
  const teardownSteps = autotest.afterEach.concat(this.afterAllSteps);
383
- const autotestPost = {
384
- externalId: autotest.externalId,
385
- title: autotest.title,
386
- name: autotest.name,
387
- description: autotest.description,
388
- links: autotest.links,
389
- labels: autotest.labels,
390
- tags: autotest.tags,
391
- namespace: autotest.namespace ?? testit_js_commons_1.Utils.getDir(this.testPath),
392
- classname: autotest.classname ?? testit_js_commons_1.Utils.getFileName(this.testPath),
393
- setup: setupSteps,
394
- steps: autotest.testSteps,
395
- teardown: teardownSteps,
396
- externalKey: autotest.externalKey,
397
- };
392
+ const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
398
393
  try {
399
394
  await this.strategy.loadAutotest(autotestPost, result.outcome);
400
395
  }
@@ -486,11 +481,23 @@ class TestItEnvironment extends jest_environment_node_1.default {
486
481
  log("Setting labels to %s", this.autotestData.name);
487
482
  this.autotestData.labels = labels.map((label) => ({ name: label }));
488
483
  }
484
+ setLayer(layer) {
485
+ log("Setting layer to %s for %s", layer, this.autotestData.name);
486
+ this.autotestData.layer = layer;
487
+ }
489
488
  setTags(tags) {
490
489
  log("Setting tags to %s", this.autotestData.name);
491
490
  this.autotestData.tags = tags;
492
491
  }
492
+ setWorkItemId(globalId) {
493
+ log("Setting work item id to %s", this.autotestData.name);
494
+ this.autotestData.workItemIds = [globalId];
495
+ }
496
+ /**
497
+ * @deprecated Use workItemId with a single globalId instead.
498
+ */
493
499
  setWorkItems(workItems) {
500
+ testit_js_commons_2.logger.warn("workItemIds is deprecated. Use workItemId with a single globalId instead.");
494
501
  log("Setting work items to %s", this.autotestData.name);
495
502
  this.autotestData.workItemIds = workItems;
496
503
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testit-adapter-jest",
3
- "version": "5.0.5",
3
+ "version": "5.0.7",
4
4
  "description": "Jest adapter for Test IT",
5
5
  "main": "dist/testitEnvironment.js",
6
6
  "scripts": {
@@ -16,7 +16,7 @@
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
18
  "debug": "^4.3.4",
19
- "testit-js-commons": "5.0.5"
19
+ "testit-js-commons": "5.0.7"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/debug": "^4.1.7",
package/types.d.ts CHANGED
@@ -6,6 +6,12 @@ declare global {
6
6
  displayName(name: string): void;
7
7
  links(links: Link[]): void;
8
8
  labels(labels: string[]): void;
9
+ layer(layer: string): void;
10
+ tags(tags: string[]): void;
11
+ workItemId(globalId: string): void;
12
+ /**
13
+ * @deprecated Use workItemId with a single globalId instead.
14
+ */
9
15
  workItemIds(workItemsIds: string[]): void;
10
16
  params(params: any): void;
11
17
  step(name: string, description?: string): void;