testit-adapter-jest 5.0.5 → 5.0.6
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 +4 -0
- package/dist/testitEnvironment.d.ts +2 -0
- package/dist/testitEnvironment.js +25 -27
- package/package.json +2 -2
- package/types.d.ts +2 -0
package/README.md
CHANGED
|
@@ -129,6 +129,7 @@ Description of metadata methods:
|
|
|
129
129
|
- `testit.title` - autotest name specified in the autotest card. If not specified, the name from the displayName method is used
|
|
130
130
|
- `testit.description` - autotest description specified in the autotest card
|
|
131
131
|
- `testit.labels` - labels listed in the autotest card
|
|
132
|
+
- `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
133
|
- `testit.tags` - tags listed in the autotest card
|
|
133
134
|
- `testit.link` - links listed in the autotest card
|
|
134
135
|
- `testit.namespace` - directory in the TMS system (default - directory's name of test)
|
|
@@ -144,12 +145,15 @@ Description of methods:
|
|
|
144
145
|
|
|
145
146
|
#### Simple test
|
|
146
147
|
```js
|
|
148
|
+
import { TestLayers } from 'testit-js-commons';
|
|
149
|
+
|
|
147
150
|
test('All annotations', () => {
|
|
148
151
|
testit.externalId('all_annotations');
|
|
149
152
|
testit.displayName('All annotations');
|
|
150
153
|
testit.title('All annotations title');
|
|
151
154
|
testit.description('Test with all annotations');
|
|
152
155
|
testit.labels(['label1', 'label2']);
|
|
156
|
+
testit.layer(TestLayers.API);
|
|
153
157
|
|
|
154
158
|
testit.addMessage('This is a message');
|
|
155
159
|
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,6 +62,7 @@ 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;
|
|
65
67
|
setWorkItems(workItems: string[]): void;
|
|
66
68
|
setParams(params: any): void;
|
|
@@ -94,6 +94,7 @@ 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),
|
|
98
99
|
workItemIds: this.setWorkItems.bind(this),
|
|
99
100
|
params: this.setParams.bind(this),
|
|
@@ -286,24 +287,15 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
286
287
|
const afterEach = autotest.afterEach;
|
|
287
288
|
return includeAfterAll ? afterEach.concat(this.afterAllSteps) : afterEach;
|
|
288
289
|
}
|
|
289
|
-
|
|
290
|
-
|
|
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 = {
|
|
290
|
+
buildAutotestPost(autotest, setupSteps, teardownSteps) {
|
|
291
|
+
return {
|
|
301
292
|
externalId: autotest.externalId,
|
|
302
293
|
title: autotest.title,
|
|
303
294
|
name: autotest.name,
|
|
304
295
|
description: autotest.description,
|
|
305
296
|
links: autotest.links,
|
|
306
297
|
labels: autotest.labels,
|
|
298
|
+
layer: autotest.layer,
|
|
307
299
|
tags: autotest.tags,
|
|
308
300
|
namespace: autotest.namespace ?? testit_js_commons_1.Utils.getDir(this.testPath),
|
|
309
301
|
classname: autotest.classname ?? testit_js_commons_1.Utils.getFileName(this.testPath),
|
|
@@ -311,7 +303,21 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
311
303
|
steps: autotest.testSteps,
|
|
312
304
|
teardown: teardownSteps,
|
|
313
305
|
externalKey: autotest.externalKey,
|
|
306
|
+
workItemIds: autotest.workItemIds,
|
|
314
307
|
};
|
|
308
|
+
}
|
|
309
|
+
async sendRealtimePayload(autotest, result, includeAfterAll) {
|
|
310
|
+
const setupSteps = this.buildSetupSteps(autotest);
|
|
311
|
+
const teardownSteps = this.buildTeardownSteps(autotest, includeAfterAll);
|
|
312
|
+
testit_js_commons_2.logger.debug("[jest-env] sendRealtimePayload", {
|
|
313
|
+
externalId: autotest.externalId,
|
|
314
|
+
outcome: result.outcome,
|
|
315
|
+
includeAfterAll,
|
|
316
|
+
setupSteps: setupSteps.length,
|
|
317
|
+
teardownSteps: teardownSteps.length,
|
|
318
|
+
testSteps: autotest.testSteps.length,
|
|
319
|
+
});
|
|
320
|
+
const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
|
|
315
321
|
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
316
322
|
await this.strategy.loadTestRun([
|
|
317
323
|
{
|
|
@@ -351,6 +357,8 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
351
357
|
if (setupSteps.length === 0 && teardownSteps.length === 0) {
|
|
352
358
|
continue;
|
|
353
359
|
}
|
|
360
|
+
const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
|
|
361
|
+
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
354
362
|
await this.strategy.updateSetupTeardown([
|
|
355
363
|
{
|
|
356
364
|
autoTestExternalId: autotest.externalId,
|
|
@@ -380,21 +388,7 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
380
388
|
log("Mapping autotest %s", autotest.name);
|
|
381
389
|
const setupSteps = this.beforeAllSteps.concat(autotest.beforeEach);
|
|
382
390
|
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
|
-
};
|
|
391
|
+
const autotestPost = this.buildAutotestPost(autotest, setupSteps, teardownSteps);
|
|
398
392
|
try {
|
|
399
393
|
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
400
394
|
}
|
|
@@ -486,6 +480,10 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
486
480
|
log("Setting labels to %s", this.autotestData.name);
|
|
487
481
|
this.autotestData.labels = labels.map((label) => ({ name: label }));
|
|
488
482
|
}
|
|
483
|
+
setLayer(layer) {
|
|
484
|
+
log("Setting layer to %s for %s", layer, this.autotestData.name);
|
|
485
|
+
this.autotestData.layer = layer;
|
|
486
|
+
}
|
|
489
487
|
setTags(tags) {
|
|
490
488
|
log("Setting tags to %s", this.autotestData.name);
|
|
491
489
|
this.autotestData.tags = tags;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-adapter-jest",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
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.
|
|
19
|
+
"testit-js-commons": "5.0.6"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/debug": "^4.1.7",
|
package/types.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ 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;
|
|
9
11
|
workItemIds(workItemsIds: string[]): void;
|
|
10
12
|
params(params: any): void;
|
|
11
13
|
step(name: string, description?: string): void;
|