testit-adapter-jest 5.0.9 → 5.1.0-TMS-5.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 +1 -6
- package/dist/testitEnvironment.d.ts +0 -6
- package/dist/testitEnvironment.js +63 -53
- package/package.json +2 -2
- package/types.d.ts +0 -6
package/README.md
CHANGED
|
@@ -123,14 +123,12 @@ $ 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.
|
|
127
|
-
- `testit.workItemIds` - deprecated, use `testit.workItemId` instead
|
|
126
|
+
- `testit.workItemIds` - a method that links autotests with manual tests. Receives the array of manual tests' IDs
|
|
128
127
|
- `testit.displayName` - internal autotest name (used in Test IT)
|
|
129
128
|
- `testit.externalId` - unique internal autotest ID (used in Test IT)
|
|
130
129
|
- `testit.title` - autotest name specified in the autotest card. If not specified, the name from the displayName method is used
|
|
131
130
|
- `testit.description` - autotest description specified in the autotest card
|
|
132
131
|
- `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
|
|
134
132
|
- `testit.tags` - tags listed in the autotest card
|
|
135
133
|
- `testit.link` - links listed in the autotest card
|
|
136
134
|
- `testit.namespace` - directory in the TMS system (default - directory's name of test)
|
|
@@ -146,15 +144,12 @@ Description of methods:
|
|
|
146
144
|
|
|
147
145
|
#### Simple test
|
|
148
146
|
```js
|
|
149
|
-
import { TestLayers } from 'testit-js-commons';
|
|
150
|
-
|
|
151
147
|
test('All annotations', () => {
|
|
152
148
|
testit.externalId('all_annotations');
|
|
153
149
|
testit.displayName('All annotations');
|
|
154
150
|
testit.title('All annotations title');
|
|
155
151
|
testit.description('Test with all annotations');
|
|
156
152
|
testit.labels(['label1', 'label2']);
|
|
157
|
-
testit.layer(TestLayers.API);
|
|
158
153
|
|
|
159
154
|
testit.addMessage('This is a message');
|
|
160
155
|
testit.addLinks([
|
|
@@ -47,7 +47,6 @@ export default class TestItEnvironment extends NodeEnvironment {
|
|
|
47
47
|
private snapshotAutotestData;
|
|
48
48
|
private buildSetupSteps;
|
|
49
49
|
private buildTeardownSteps;
|
|
50
|
-
private buildAutotestPost;
|
|
51
50
|
private sendRealtimePayload;
|
|
52
51
|
/** afterAll hooks run after all tests; patch teardown when importRealtime is enabled. */
|
|
53
52
|
private flushRealtimeTeardown;
|
|
@@ -62,12 +61,7 @@ export default class TestItEnvironment extends NodeEnvironment {
|
|
|
62
61
|
addAttachments(attachments: string[]): void;
|
|
63
62
|
setLinks(links: Link[]): void;
|
|
64
63
|
setLabels(labels: string[]): void;
|
|
65
|
-
setLayer(layer: string): void;
|
|
66
64
|
setTags(tags: string[]): void;
|
|
67
|
-
setWorkItemId(globalId: string): void;
|
|
68
|
-
/**
|
|
69
|
-
* @deprecated Use workItemId with a single globalId instead.
|
|
70
|
-
*/
|
|
71
65
|
setWorkItems(workItems: string[]): void;
|
|
72
66
|
setParams(params: any): void;
|
|
73
67
|
setNameSpace(nameSpace: string): void;
|
|
@@ -94,9 +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),
|
|
98
97
|
tags: this.setTags.bind(this),
|
|
99
|
-
workItemId: this.setWorkItemId.bind(this),
|
|
100
98
|
workItemIds: this.setWorkItems.bind(this),
|
|
101
99
|
params: this.setParams.bind(this),
|
|
102
100
|
step: this.startStep.bind(this),
|
|
@@ -243,9 +241,9 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
243
241
|
startedOn: test.startedAt ? new Date(test.startedAt) : undefined,
|
|
244
242
|
duration: test.duration ?? undefined,
|
|
245
243
|
traces: errorTraces,
|
|
246
|
-
attachments: this.additions.attachments,
|
|
244
|
+
attachments: [...this.additions.attachments],
|
|
247
245
|
message: this.additions.messages.join("\n").concat(errorMessage ?? ""),
|
|
248
|
-
links: this.additions.links,
|
|
246
|
+
links: [...this.additions.links],
|
|
249
247
|
};
|
|
250
248
|
if (this.importRealtime) {
|
|
251
249
|
this.realtimeSent.push({ autotest: autotestSnapshot, result });
|
|
@@ -261,6 +259,8 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
261
259
|
catch (err) {
|
|
262
260
|
testit_js_commons_2.logger.error("Failed realtime send in Jest environment:", this.formatError(err));
|
|
263
261
|
}
|
|
262
|
+
// Keep sync-storage LastStatus fresh; otherwise Force Work X fires after ~60s.
|
|
263
|
+
await Promise.resolve(this.strategy.touchWorker?.()).catch(() => undefined);
|
|
264
264
|
}
|
|
265
265
|
else {
|
|
266
266
|
this.autotests.push(autotestSnapshot);
|
|
@@ -288,54 +288,42 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
288
288
|
const afterEach = autotest.afterEach;
|
|
289
289
|
return includeAfterAll ? afterEach.concat(this.afterAllSteps) : afterEach;
|
|
290
290
|
}
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
async sendRealtimePayload(autotest, result, includeAfterAll) {
|
|
292
|
+
const setupSteps = this.buildSetupSteps(autotest);
|
|
293
|
+
const teardownSteps = this.buildTeardownSteps(autotest, includeAfterAll);
|
|
294
|
+
testit_js_commons_2.logger.debug("[jest-env] sendRealtimePayload", {
|
|
295
|
+
externalId: autotest.externalId,
|
|
296
|
+
outcome: result.outcome,
|
|
297
|
+
includeAfterAll,
|
|
298
|
+
setupSteps: setupSteps.length,
|
|
299
|
+
teardownSteps: teardownSteps.length,
|
|
300
|
+
testSteps: autotest.testSteps.length,
|
|
301
|
+
});
|
|
302
|
+
// Mutate the same AutotestResult instance that may be queued as deferred InProgress final.
|
|
303
|
+
// flushRealtimeTeardown patches teardownResults on this ref before strategy.teardown().
|
|
304
|
+
result.stepResults = autotest.testSteps;
|
|
305
|
+
result.setupResults = setupSteps;
|
|
306
|
+
result.teardownResults = teardownSteps;
|
|
307
|
+
result.parameters = autotest.parameters !== undefined ? (0, utils_1.mapParams)(autotest.parameters) : undefined;
|
|
308
|
+
const autotestPost = {
|
|
293
309
|
externalId: autotest.externalId,
|
|
294
310
|
title: autotest.title,
|
|
295
311
|
name: autotest.name,
|
|
296
312
|
description: autotest.description,
|
|
297
313
|
links: autotest.links,
|
|
298
314
|
labels: autotest.labels,
|
|
299
|
-
layer: autotest.layer,
|
|
300
315
|
tags: autotest.tags,
|
|
301
316
|
namespace: autotest.namespace ?? testit_js_commons_1.Utils.getDir(this.testPath),
|
|
302
317
|
classname: autotest.classname ?? testit_js_commons_1.Utils.getFileName(this.testPath),
|
|
303
318
|
setup: setupSteps,
|
|
304
319
|
steps: autotest.testSteps,
|
|
305
|
-
teardown
|
|
320
|
+
// Omit teardown until afterAll is known — empty [] would clear a previous afterAll on TMS.
|
|
321
|
+
teardown: includeAfterAll ? teardownSteps : undefined,
|
|
306
322
|
externalKey: autotest.externalKey,
|
|
307
323
|
workItemIds: autotest.workItemIds,
|
|
308
324
|
};
|
|
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);
|
|
322
325
|
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
323
|
-
await this.strategy.loadTestRun([
|
|
324
|
-
{
|
|
325
|
-
autoTestExternalId: autotestPost.externalId,
|
|
326
|
-
outcome: result.outcome,
|
|
327
|
-
startedOn: result.startedOn,
|
|
328
|
-
duration: result.duration,
|
|
329
|
-
attachments: result.attachments,
|
|
330
|
-
message: result.message,
|
|
331
|
-
links: result.links,
|
|
332
|
-
stepResults: autotest.testSteps,
|
|
333
|
-
traces: result.traces,
|
|
334
|
-
setupResults: setupSteps,
|
|
335
|
-
teardownResults: teardownSteps,
|
|
336
|
-
parameters: autotest.parameters !== undefined ? (0, utils_1.mapParams)(autotest.parameters) : undefined,
|
|
337
|
-
},
|
|
338
|
-
]);
|
|
326
|
+
await this.strategy.loadTestRun([result]);
|
|
339
327
|
}
|
|
340
328
|
/** afterAll hooks run after all tests; patch teardown when importRealtime is enabled. */
|
|
341
329
|
async flushRealtimeTeardown() {
|
|
@@ -351,14 +339,34 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
351
339
|
tests: this.realtimeSent.length,
|
|
352
340
|
afterAllSteps: this.afterAllSteps.length,
|
|
353
341
|
});
|
|
342
|
+
// Patch shared result refs first so deferred final POST (strategy.teardown) includes afterAll.
|
|
343
|
+
for (const { autotest, result } of this.realtimeSent) {
|
|
344
|
+
result.setupResults = this.buildSetupSteps(autotest);
|
|
345
|
+
result.teardownResults = this.buildTeardownSteps(autotest, true);
|
|
346
|
+
}
|
|
354
347
|
for (const { autotest, result } of this.realtimeSent) {
|
|
355
348
|
try {
|
|
356
|
-
const setupSteps =
|
|
357
|
-
const teardownSteps =
|
|
349
|
+
const setupSteps = result.setupResults ?? [];
|
|
350
|
+
const teardownSteps = result.teardownResults ?? [];
|
|
358
351
|
if (setupSteps.length === 0 && teardownSteps.length === 0) {
|
|
359
352
|
continue;
|
|
360
353
|
}
|
|
361
|
-
const autotestPost =
|
|
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
|
+
};
|
|
362
370
|
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
363
371
|
await this.strategy.updateSetupTeardown([
|
|
364
372
|
{
|
|
@@ -389,7 +397,21 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
389
397
|
log("Mapping autotest %s", autotest.name);
|
|
390
398
|
const setupSteps = this.beforeAllSteps.concat(autotest.beforeEach);
|
|
391
399
|
const teardownSteps = autotest.afterEach.concat(this.afterAllSteps);
|
|
392
|
-
const autotestPost =
|
|
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
|
+
};
|
|
393
415
|
try {
|
|
394
416
|
await this.strategy.loadAutotest(autotestPost, result.outcome);
|
|
395
417
|
}
|
|
@@ -481,23 +503,11 @@ class TestItEnvironment extends jest_environment_node_1.default {
|
|
|
481
503
|
log("Setting labels to %s", this.autotestData.name);
|
|
482
504
|
this.autotestData.labels = labels.map((label) => ({ name: label }));
|
|
483
505
|
}
|
|
484
|
-
setLayer(layer) {
|
|
485
|
-
log("Setting layer to %s for %s", layer, this.autotestData.name);
|
|
486
|
-
this.autotestData.layer = layer;
|
|
487
|
-
}
|
|
488
506
|
setTags(tags) {
|
|
489
507
|
log("Setting tags to %s", this.autotestData.name);
|
|
490
508
|
this.autotestData.tags = tags;
|
|
491
509
|
}
|
|
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
|
-
*/
|
|
499
510
|
setWorkItems(workItems) {
|
|
500
|
-
testit_js_commons_2.logger.warn("workItemIds is deprecated. Use workItemId with a single globalId instead.");
|
|
501
511
|
log("Setting work items to %s", this.autotestData.name);
|
|
502
512
|
this.autotestData.workItemIds = workItems;
|
|
503
513
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-adapter-jest",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.1.0-TMS-5.8",
|
|
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.1.0-TMS-5.8"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/debug": "^4.1.7",
|
package/types.d.ts
CHANGED
|
@@ -6,12 +6,6 @@ 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
|
-
*/
|
|
15
9
|
workItemIds(workItemsIds: string[]): void;
|
|
16
10
|
params(params: any): void;
|
|
17
11
|
step(name: string, description?: string): void;
|