testit-adapter-jest 5.1.0-TMS-6.0 → 5.1.1
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 +6 -1
- package/dist/testitEnvironment.d.ts +6 -0
- package/dist/testitEnvironment.js +41 -48
- package/package.json +2 -2
- package/types.d.ts +6 -0
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.
|
|
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),
|
|
@@ -288,6 +290,25 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
288
290
|
const afterEach = autotest.afterEach;
|
|
289
291
|
return includeAfterAll ? afterEach.concat(this.afterAllSteps) : afterEach;
|
|
290
292
|
}
|
|
293
|
+
buildAutotestPost(autotest, setupSteps, teardownSteps) {
|
|
294
|
+
return {
|
|
295
|
+
externalId: autotest.externalId,
|
|
296
|
+
title: autotest.title,
|
|
297
|
+
name: autotest.name,
|
|
298
|
+
description: autotest.description,
|
|
299
|
+
links: autotest.links,
|
|
300
|
+
labels: autotest.labels,
|
|
301
|
+
layer: autotest.layer,
|
|
302
|
+
tags: autotest.tags,
|
|
303
|
+
namespace: autotest.namespace ?? testit_js_commons_1.Utils.getDir(this.testPath),
|
|
304
|
+
classname: autotest.classname ?? testit_js_commons_1.Utils.getFileName(this.testPath),
|
|
305
|
+
setup: setupSteps,
|
|
306
|
+
steps: autotest.testSteps,
|
|
307
|
+
teardown: teardownSteps,
|
|
308
|
+
externalKey: autotest.externalKey,
|
|
309
|
+
workItemIds: autotest.workItemIds,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
291
312
|
async sendRealtimePayload(autotest, result, includeAfterAll) {
|
|
292
313
|
const setupSteps = this.buildSetupSteps(autotest);
|
|
293
314
|
const teardownSteps = this.buildTeardownSteps(autotest, includeAfterAll);
|
|
@@ -305,23 +326,12 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
305
326
|
result.setupResults = setupSteps;
|
|
306
327
|
result.teardownResults = teardownSteps;
|
|
307
328
|
result.parameters = autotest.parameters !== undefined ? (0, utils_1.mapParams)(autotest.parameters) : undefined;
|
|
308
|
-
const autotestPost =
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
labels: autotest.labels,
|
|
315
|
-
tags: autotest.tags,
|
|
316
|
-
namespace: autotest.namespace ?? testit_js_commons_1.Utils.getDir(this.testPath),
|
|
317
|
-
classname: autotest.classname ?? testit_js_commons_1.Utils.getFileName(this.testPath),
|
|
318
|
-
setup: setupSteps,
|
|
319
|
-
steps: autotest.testSteps,
|
|
320
|
-
// Omit teardown until afterAll is known — empty [] would clear a previous afterAll on TMS.
|
|
321
|
-
teardown: includeAfterAll ? teardownSteps : undefined,
|
|
322
|
-
externalKey: autotest.externalKey,
|
|
323
|
-
workItemIds: autotest.workItemIds,
|
|
324
|
-
};
|
|
329
|
+
const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
|
|
330
|
+
// Avoid writing empty teardown to the Autotest card before afterAll is known —
|
|
331
|
+
// a full replace with [] would clear a previously uploaded afterAll until flush.
|
|
332
|
+
if (!includeAfterAll) {
|
|
333
|
+
autotestPost.teardown = undefined;
|
|
334
|
+
}
|
|
325
335
|
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
326
336
|
await this.strategy.loadTestRun([result]);
|
|
327
337
|
}
|
|
@@ -351,22 +361,7 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
351
361
|
if (setupSteps.length === 0 && teardownSteps.length === 0) {
|
|
352
362
|
continue;
|
|
353
363
|
}
|
|
354
|
-
const autotestPost =
|
|
355
|
-
externalId: autotest.externalId,
|
|
356
|
-
title: autotest.title,
|
|
357
|
-
name: autotest.name,
|
|
358
|
-
description: autotest.description,
|
|
359
|
-
links: autotest.links,
|
|
360
|
-
labels: autotest.labels,
|
|
361
|
-
tags: autotest.tags,
|
|
362
|
-
namespace: autotest.namespace ?? testit_js_commons_1.Utils.getDir(this.testPath),
|
|
363
|
-
classname: autotest.classname ?? testit_js_commons_1.Utils.getFileName(this.testPath),
|
|
364
|
-
setup: setupSteps,
|
|
365
|
-
steps: autotest.testSteps,
|
|
366
|
-
teardown: teardownSteps,
|
|
367
|
-
externalKey: autotest.externalKey,
|
|
368
|
-
workItemIds: autotest.workItemIds,
|
|
369
|
-
};
|
|
364
|
+
const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
|
|
370
365
|
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
371
366
|
await this.strategy.updateSetupTeardown([
|
|
372
367
|
{
|
|
@@ -397,21 +392,7 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
397
392
|
log("Mapping autotest %s", autotest.name);
|
|
398
393
|
const setupSteps = this.beforeAllSteps.concat(autotest.beforeEach);
|
|
399
394
|
const teardownSteps = autotest.afterEach.concat(this.afterAllSteps);
|
|
400
|
-
const autotestPost =
|
|
401
|
-
externalId: autotest.externalId,
|
|
402
|
-
title: autotest.title,
|
|
403
|
-
name: autotest.name,
|
|
404
|
-
description: autotest.description,
|
|
405
|
-
links: autotest.links,
|
|
406
|
-
labels: autotest.labels,
|
|
407
|
-
tags: autotest.tags,
|
|
408
|
-
namespace: autotest.namespace ?? testit_js_commons_1.Utils.getDir(this.testPath),
|
|
409
|
-
classname: autotest.classname ?? testit_js_commons_1.Utils.getFileName(this.testPath),
|
|
410
|
-
setup: setupSteps,
|
|
411
|
-
steps: autotest.testSteps,
|
|
412
|
-
teardown: teardownSteps,
|
|
413
|
-
externalKey: autotest.externalKey,
|
|
414
|
-
};
|
|
395
|
+
const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
|
|
415
396
|
try {
|
|
416
397
|
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
417
398
|
}
|
|
@@ -503,11 +484,23 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
503
484
|
log("Setting labels to %s", this.autotestData.name);
|
|
504
485
|
this.autotestData.labels = labels.map((label) => ({ name: label }));
|
|
505
486
|
}
|
|
487
|
+
setLayer(layer) {
|
|
488
|
+
log("Setting layer to %s for %s", layer, this.autotestData.name);
|
|
489
|
+
this.autotestData.layer = layer;
|
|
490
|
+
}
|
|
506
491
|
setTags(tags) {
|
|
507
492
|
log("Setting tags to %s", this.autotestData.name);
|
|
508
493
|
this.autotestData.tags = tags;
|
|
509
494
|
}
|
|
495
|
+
setWorkItemId(globalId) {
|
|
496
|
+
log("Setting work item id to %s", this.autotestData.name);
|
|
497
|
+
this.autotestData.workItemIds = [globalId];
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* @deprecated Use workItemId with a single globalId instead.
|
|
501
|
+
*/
|
|
510
502
|
setWorkItems(workItems) {
|
|
503
|
+
testit_js_commons_2.logger.warn("workItemIds is deprecated. Use workItemId with a single globalId instead.");
|
|
511
504
|
log("Setting work items to %s", this.autotestData.name);
|
|
512
505
|
this.autotestData.workItemIds = workItems;
|
|
513
506
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-adapter-jest",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.1",
|
|
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.1.
|
|
19
|
+
"testit-js-commons": "5.1.1"
|
|
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;
|