html-reporter 9.15.0 → 9.16.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/build/hermione.d.ts +4 -2
- package/build/hermione.js +96 -58
- package/build/hermione.js.map +1 -1
- package/build/lib/cache.d.ts +8 -0
- package/build/lib/cache.js +29 -0
- package/build/lib/cache.js.map +1 -0
- package/build/lib/cli-commands/gui.js +1 -1
- package/build/lib/cli-commands/gui.js.map +1 -1
- package/build/lib/cli-commands/merge-reports.js +6 -1
- package/build/lib/cli-commands/merge-reports.js.map +1 -1
- package/build/lib/cli-commands/remove-unused-screens/utils.d.ts +4 -4
- package/build/lib/common-utils.d.ts +19 -10
- package/build/lib/common-utils.js +57 -10
- package/build/lib/common-utils.js.map +1 -1
- package/build/lib/config/custom-gui-asserts.js +24 -4
- package/build/lib/config/custom-gui-asserts.js.map +1 -1
- package/build/lib/constants/database.d.ts +60 -7
- package/build/lib/constants/database.js.map +1 -1
- package/build/lib/constants/errors.d.ts +2 -5
- package/build/lib/constants/errors.js +5 -8
- package/build/lib/constants/errors.js.map +1 -1
- package/build/lib/constants/index.d.ts +1 -0
- package/build/lib/constants/index.js +1 -0
- package/build/lib/constants/index.js.map +1 -1
- package/build/lib/constants/tests.d.ts +3 -0
- package/build/lib/constants/tests.js +4 -1
- package/build/lib/constants/tests.js.map +1 -1
- package/build/lib/db-utils/common.js.map +1 -1
- package/build/lib/db-utils/server.d.ts +3 -3
- package/build/lib/db-utils/server.js +4 -4
- package/build/lib/db-utils/server.js.map +1 -1
- package/build/lib/errors/index.d.ts +6 -6
- package/build/lib/gui/api/facade.d.ts +6 -7
- package/build/lib/gui/api/facade.js +13 -7
- package/build/lib/gui/api/facade.js.map +1 -1
- package/build/lib/gui/api/index.d.ts +16 -8
- package/build/lib/gui/api/index.js +9 -6
- package/build/lib/gui/api/index.js.map +1 -1
- package/build/lib/gui/app.d.ts +27 -62
- package/build/lib/gui/app.js +27 -23
- package/build/lib/gui/app.js.map +1 -1
- package/build/lib/gui/constants/client-events.d.ts +11 -6
- package/build/lib/gui/constants/client-events.js +4 -2
- package/build/lib/gui/constants/client-events.js.map +1 -1
- package/build/lib/gui/constants/custom-gui-control-types.d.ts +2 -2
- package/build/lib/gui/constants/custom-gui-control-types.js +5 -5
- package/build/lib/gui/constants/custom-gui-control-types.js.map +1 -1
- package/build/lib/gui/constants/gui-events.d.ts +7 -2
- package/build/lib/gui/constants/gui-events.js +4 -2
- package/build/lib/gui/constants/gui-events.js.map +1 -1
- package/build/lib/gui/constants/index.d.ts +4 -0
- package/build/lib/gui/constants/index.js +21 -0
- package/build/lib/gui/constants/index.js.map +1 -0
- package/build/lib/gui/constants/server.d.ts +3 -3
- package/build/lib/gui/constants/server.js +6 -6
- package/build/lib/gui/constants/server.js.map +1 -1
- package/build/lib/gui/event-source.d.ts +6 -5
- package/build/lib/gui/event-source.js +11 -5
- package/build/lib/gui/event-source.js.map +1 -1
- package/build/lib/gui/index.d.ts +19 -8
- package/build/lib/gui/index.js +2 -2
- package/build/lib/gui/index.js.map +1 -1
- package/build/lib/gui/routes/plugins.d.ts +3 -2
- package/build/lib/gui/routes/plugins.js +17 -14
- package/build/lib/gui/routes/plugins.js.map +1 -1
- package/build/lib/gui/server.d.ts +3 -8
- package/build/lib/gui/server.js +65 -52
- package/build/lib/gui/server.js.map +1 -1
- package/build/lib/gui/tool-runner/index.d.ts +52 -105
- package/build/lib/gui/tool-runner/index.js +190 -124
- package/build/lib/gui/tool-runner/index.js.map +1 -1
- package/build/lib/gui/tool-runner/report-subscriber.d.ts +4 -2
- package/build/lib/gui/tool-runner/report-subscriber.js +39 -76
- package/build/lib/gui/tool-runner/report-subscriber.js.map +1 -1
- package/build/lib/gui/tool-runner/runner/all-test-runner.d.ts +4 -3
- package/build/lib/gui/tool-runner/runner/all-test-runner.js +7 -4
- package/build/lib/gui/tool-runner/runner/all-test-runner.js.map +1 -1
- package/build/lib/gui/tool-runner/runner/index.d.ts +3 -3
- package/build/lib/gui/tool-runner/runner/index.js +14 -8
- package/build/lib/gui/tool-runner/runner/index.js.map +1 -1
- package/build/lib/gui/tool-runner/runner/runner.d.ts +12 -5
- package/build/lib/gui/tool-runner/runner/runner.js +6 -3
- package/build/lib/gui/tool-runner/runner/runner.js.map +1 -1
- package/build/lib/gui/tool-runner/runner/specific-test-runner.d.ts +7 -6
- package/build/lib/gui/tool-runner/runner/specific-test-runner.js +7 -4
- package/build/lib/gui/tool-runner/runner/specific-test-runner.js.map +1 -1
- package/build/lib/gui/tool-runner/utils.d.ts +6 -7
- package/build/lib/gui/tool-runner/utils.js +48 -38
- package/build/lib/gui/tool-runner/utils.js.map +1 -1
- package/build/lib/history-utils.d.ts +1 -1
- package/build/lib/history-utils.js +6 -6
- package/build/lib/history-utils.js.map +1 -1
- package/build/lib/image-store.d.ts +6 -7
- package/build/lib/image-store.js +5 -4
- package/build/lib/image-store.js.map +1 -1
- package/build/lib/images-info-saver.d.ts +28 -0
- package/build/lib/images-info-saver.js +168 -0
- package/build/lib/images-info-saver.js.map +1 -0
- package/build/lib/local-image-file-saver.d.ts +2 -0
- package/build/lib/{local-images-saver.js → local-image-file-saver.js} +3 -3
- package/build/lib/local-image-file-saver.js.map +1 -0
- package/build/lib/merge-reports/index.d.ts +3 -2
- package/build/lib/merge-reports/index.js +26 -9
- package/build/lib/merge-reports/index.js.map +1 -1
- package/build/lib/plugin-api.d.ts +5 -5
- package/build/lib/plugin-api.js +2 -2
- package/build/lib/plugin-api.js.map +1 -1
- package/build/lib/report-builder/gui.d.ts +39 -86
- package/build/lib/report-builder/gui.js +75 -106
- package/build/lib/report-builder/gui.js.map +1 -1
- package/build/lib/report-builder/static.d.ts +19 -27
- package/build/lib/report-builder/static.js +41 -83
- package/build/lib/report-builder/static.js.map +1 -1
- package/build/lib/reporter-helpers.d.ts +7 -3
- package/build/lib/reporter-helpers.js +83 -28
- package/build/lib/reporter-helpers.js.map +1 -1
- package/build/lib/server-utils.d.ts +16 -13
- package/build/lib/server-utils.js +36 -23
- package/build/lib/server-utils.js.map +1 -1
- package/build/lib/sqlite-client.d.ts +58 -0
- package/build/lib/{sqlite-adapter.js → sqlite-client.js} +32 -62
- package/build/lib/sqlite-client.js.map +1 -0
- package/build/lib/static/gui.html +1 -1
- package/build/lib/static/gui.min.css +2 -1
- package/build/lib/static/gui.min.js +1 -124
- package/build/lib/static/index.html +1 -1
- package/build/lib/static/report.min.css +1 -1
- package/build/lib/static/report.min.js +1 -124
- package/build/lib/test-adapter/hermione.d.ts +7 -14
- package/build/lib/test-adapter/hermione.js +79 -86
- package/build/lib/test-adapter/hermione.js.map +1 -1
- package/build/lib/test-adapter/index.d.ts +8 -10
- package/build/lib/test-adapter/index.js +0 -15
- package/build/lib/test-adapter/index.js.map +1 -1
- package/build/lib/test-adapter/playwright.d.ts +7 -11
- package/build/lib/test-adapter/playwright.js +55 -71
- package/build/lib/test-adapter/playwright.js.map +1 -1
- package/build/lib/test-adapter/reporter.d.ts +31 -0
- package/build/lib/test-adapter/reporter.js +87 -0
- package/build/lib/test-adapter/reporter.js.map +1 -0
- package/build/lib/test-adapter/sqlite.d.ts +37 -0
- package/build/lib/test-adapter/sqlite.js +118 -0
- package/build/lib/test-adapter/sqlite.js.map +1 -0
- package/build/lib/test-adapter/transformers/db.d.ts +11 -0
- package/build/lib/test-adapter/transformers/db.js +40 -0
- package/build/lib/test-adapter/transformers/db.js.map +1 -0
- package/build/lib/test-adapter/transformers/tree.d.ts +11 -0
- package/build/lib/test-adapter/transformers/tree.js +24 -0
- package/build/lib/test-adapter/transformers/tree.js.map +1 -0
- package/build/lib/test-adapter/utils/index.d.ts +5 -0
- package/build/lib/test-adapter/utils/index.js +61 -0
- package/build/lib/test-adapter/utils/index.js.map +1 -0
- package/build/lib/test-attempt-manager.d.ts +13 -0
- package/build/lib/test-attempt-manager.js +39 -0
- package/build/lib/test-attempt-manager.js.map +1 -0
- package/build/lib/tests-tree-builder/base.d.ts +19 -11
- package/build/lib/tests-tree-builder/base.js +10 -9
- package/build/lib/tests-tree-builder/base.js.map +1 -1
- package/build/lib/tests-tree-builder/gui.d.ts +53 -66
- package/build/lib/tests-tree-builder/gui.js +30 -33
- package/build/lib/tests-tree-builder/gui.js.map +1 -1
- package/build/lib/tests-tree-builder/static.d.ts +5 -4
- package/build/lib/tests-tree-builder/static.js +9 -24
- package/build/lib/tests-tree-builder/static.js.map +1 -1
- package/build/lib/types.d.ts +70 -61
- package/build/lib/workers/create-workers.d.ts +1 -0
- package/build/lib/workers/worker.d.ts +2 -2
- package/build/lib/workers/worker.js +2 -2
- package/build/lib/workers/worker.js.map +1 -1
- package/build/package.json +27 -16
- package/build/playwright.d.ts +4 -3
- package/build/playwright.js +30 -23
- package/build/playwright.js.map +1 -1
- package/package.json +27 -16
- package/build/lib/errors/db-not-initialized-error.d.ts +0 -3
- package/build/lib/errors/db-not-initialized-error.js +0 -10
- package/build/lib/errors/db-not-initialized-error.js.map +0 -1
- package/build/lib/image-handler.d.ts +0 -34
- package/build/lib/image-handler.js +0 -273
- package/build/lib/image-handler.js.map +0 -1
- package/build/lib/local-images-saver.d.ts +0 -2
- package/build/lib/local-images-saver.js.map +0 -1
- package/build/lib/plugin-adapter.d.ts +0 -17
- package/build/lib/plugin-adapter.js +0 -86
- package/build/lib/plugin-adapter.js.map +0 -1
- package/build/lib/sqlite-adapter.d.ts +0 -68
- package/build/lib/sqlite-adapter.js.map +0 -1
- package/build/lib/test-adapter/cache/hermione.d.ts +0 -1
- package/build/lib/test-adapter/cache/hermione.js +0 -5
- package/build/lib/test-adapter/cache/hermione.js.map +0 -1
- package/build/lib/test-adapter/cache/playwright.d.ts +0 -1
- package/build/lib/test-adapter/cache/playwright.js +0 -5
- package/build/lib/test-adapter/cache/playwright.js.map +0 -1
|
@@ -1,32 +1,28 @@
|
|
|
1
|
+
import Hermione, { Test as HermioneTest } from 'hermione';
|
|
2
|
+
import { ValueOf } from 'type-fest';
|
|
1
3
|
import { TestStatus } from '../constants';
|
|
2
|
-
import {
|
|
3
|
-
import { ImagesInfoFormatter } from '../image-handler';
|
|
4
|
+
import { ErrorDetails, HermioneTestResult, ImageBase64, ImageInfoFull, TestError } from '../types';
|
|
4
5
|
import { ReporterTestResult } from './index';
|
|
6
|
+
export declare const getStatus: (eventName: ValueOf<Hermione['events']>, events: Hermione['events'], testResult: HermioneTestResult) => TestStatus;
|
|
5
7
|
export interface HermioneTestAdapterOptions {
|
|
8
|
+
attempt: number;
|
|
6
9
|
status: TestStatus;
|
|
7
|
-
imagesInfoFormatter: ImagesInfoFormatter;
|
|
8
10
|
}
|
|
9
11
|
export declare class HermioneTestAdapter implements ReporterTestResult {
|
|
10
|
-
private _imagesInfoFormatter;
|
|
11
12
|
private _testResult;
|
|
12
|
-
private _testId;
|
|
13
13
|
private _errorDetails;
|
|
14
14
|
private _timestamp;
|
|
15
15
|
private _attempt;
|
|
16
16
|
private _status;
|
|
17
17
|
static create<T extends HermioneTestAdapter>(this: new (testResult: HermioneTestResult, options: HermioneTestAdapterOptions) => T, testResult: HermioneTestResult, options: HermioneTestAdapterOptions): T;
|
|
18
|
-
constructor(testResult: HermioneTestResult, {
|
|
19
|
-
image?: boolean;
|
|
18
|
+
constructor(testResult: HermioneTest | HermioneTestResult, { attempt, status }: HermioneTestAdapterOptions);
|
|
20
19
|
get fullName(): string;
|
|
21
20
|
get skipReason(): string;
|
|
22
21
|
get status(): TestStatus;
|
|
23
22
|
get sessionId(): string;
|
|
24
23
|
get browserId(): string;
|
|
25
|
-
get imagesInfo(): ImageInfoFull[]
|
|
26
|
-
get origAttempt(): number | undefined;
|
|
24
|
+
get imagesInfo(): ImageInfoFull[];
|
|
27
25
|
get attempt(): number;
|
|
28
|
-
set attempt(attemptNum: number);
|
|
29
|
-
get assertViewResults(): AssertViewResult[];
|
|
30
26
|
get history(): string[];
|
|
31
27
|
get error(): undefined | TestError;
|
|
32
28
|
get imageDir(): string;
|
|
@@ -35,7 +31,6 @@ export declare class HermioneTestAdapter implements ReporterTestResult {
|
|
|
35
31
|
};
|
|
36
32
|
get testPath(): string[];
|
|
37
33
|
get id(): string;
|
|
38
|
-
get isUpdated(): boolean | undefined;
|
|
39
34
|
get screenshot(): ImageBase64 | undefined;
|
|
40
35
|
get description(): string | undefined;
|
|
41
36
|
get meta(): Record<string, unknown>;
|
|
@@ -45,6 +40,4 @@ export declare class HermioneTestAdapter implements ReporterTestResult {
|
|
|
45
40
|
get multipleTabs(): boolean;
|
|
46
41
|
get timestamp(): number | undefined;
|
|
47
42
|
set timestamp(timestamp: number | undefined);
|
|
48
|
-
saveErrorDetails(reportPath: string): Promise<void>;
|
|
49
|
-
decreaseAttemptNumber(): void;
|
|
50
43
|
}
|
|
@@ -1,41 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.HermioneTestAdapter = void 0;
|
|
30
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
31
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
6
|
+
exports.HermioneTestAdapter = exports.getStatus = void 0;
|
|
32
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
33
9
|
const history_utils_1 = require("../history-utils");
|
|
34
10
|
const constants_1 = require("../constants");
|
|
35
11
|
const common_utils_1 = require("../common-utils");
|
|
36
|
-
const utils = __importStar(require("../server-utils"));
|
|
37
12
|
const plugin_utils_1 = require("../plugin-utils");
|
|
38
|
-
const
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const getStatus = (eventName, events, testResult) => {
|
|
15
|
+
if (eventName === events.TEST_PASS) {
|
|
16
|
+
return constants_1.TestStatus.SUCCESS;
|
|
17
|
+
}
|
|
18
|
+
else if (eventName === events.TEST_PENDING) {
|
|
19
|
+
return constants_1.TestStatus.SKIPPED;
|
|
20
|
+
}
|
|
21
|
+
else if (eventName === events.RETRY || eventName === events.TEST_FAIL) {
|
|
22
|
+
return (0, common_utils_1.hasFailedImages)(testResult.assertViewResults) ? constants_1.TestStatus.FAIL : constants_1.TestStatus.ERROR;
|
|
23
|
+
}
|
|
24
|
+
else if (eventName === events.TEST_BEGIN) {
|
|
25
|
+
return constants_1.TestStatus.RUNNING;
|
|
26
|
+
}
|
|
27
|
+
return constants_1.TestStatus.IDLE;
|
|
28
|
+
};
|
|
29
|
+
exports.getStatus = getStatus;
|
|
39
30
|
const getSkipComment = (suite) => {
|
|
40
31
|
return suite.skipReason || suite.parent && getSkipComment(suite.parent);
|
|
41
32
|
};
|
|
@@ -46,19 +37,15 @@ class HermioneTestAdapter {
|
|
|
46
37
|
static create(testResult, options) {
|
|
47
38
|
return new this(testResult, options);
|
|
48
39
|
}
|
|
49
|
-
constructor(testResult, {
|
|
50
|
-
this._imagesInfoFormatter = imagesInfoFormatter;
|
|
40
|
+
constructor(testResult, { attempt, status }) {
|
|
51
41
|
this._testResult = testResult;
|
|
52
|
-
this._testId = (0, common_utils_1.mkTestId)(testResult.fullTitle(), testResult.browserId);
|
|
53
42
|
this._errorDetails = null;
|
|
54
|
-
this._timestamp = this._testResult.timestamp
|
|
43
|
+
this._timestamp = this._testResult.timestamp ??
|
|
44
|
+
this._testResult.startTime ?? Date.now();
|
|
55
45
|
this._status = status;
|
|
56
46
|
const browserVersion = lodash_1.default.get(this._testResult, 'meta.browserVersion', this._testResult.browserVersion);
|
|
57
47
|
lodash_1.default.set(this._testResult, 'meta.browserVersion', browserVersion);
|
|
58
|
-
|
|
59
|
-
hermione_1.testsAttempts.set(this._testId, lodash_1.default.isUndefined(hermione_1.testsAttempts.get(this._testId)) ? 0 : hermione_1.testsAttempts.get(this._testId) + 1);
|
|
60
|
-
}
|
|
61
|
-
this._attempt = hermione_1.testsAttempts.get(this._testId) || 0;
|
|
48
|
+
this._attempt = attempt;
|
|
62
49
|
}
|
|
63
50
|
get fullName() {
|
|
64
51
|
return this._testResult.fullTitle();
|
|
@@ -70,27 +57,68 @@ class HermioneTestAdapter {
|
|
|
70
57
|
return this._status;
|
|
71
58
|
}
|
|
72
59
|
get sessionId() {
|
|
73
|
-
return this._testResult.sessionId ||
|
|
60
|
+
return this._testResult.sessionId || constants_1.UNKNOWN_SESSION_ID;
|
|
74
61
|
}
|
|
75
62
|
get browserId() {
|
|
76
63
|
return this._testResult.browserId;
|
|
77
64
|
}
|
|
78
65
|
get imagesInfo() {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
const { assertViewResults = [] } = this._testResult;
|
|
67
|
+
const imagesInfo = assertViewResults.map((assertResult) => {
|
|
68
|
+
if ((0, common_utils_1.isImageDiffError)(assertResult)) {
|
|
69
|
+
const diffBufferImg = assertResult.diffBuffer ? { buffer: assertResult.diffBuffer } : undefined;
|
|
70
|
+
const diffImg = assertResult.diffImg ?? diffBufferImg;
|
|
71
|
+
return {
|
|
72
|
+
status: constants_1.FAIL,
|
|
73
|
+
stateName: assertResult.stateName,
|
|
74
|
+
refImg: assertResult.refImg,
|
|
75
|
+
actualImg: assertResult.currImg,
|
|
76
|
+
...(diffImg ? { diffImg } : {}),
|
|
77
|
+
expectedImg: lodash_1.default.clone(assertResult.refImg),
|
|
78
|
+
diffClusters: assertResult.diffClusters,
|
|
79
|
+
diffOptions: assertResult.diffOpts
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
else if ((0, common_utils_1.isNoRefImageError)(assertResult)) {
|
|
83
|
+
return {
|
|
84
|
+
status: constants_1.ERROR,
|
|
85
|
+
stateName: assertResult.stateName,
|
|
86
|
+
error: lodash_1.default.pick(assertResult, ['message', 'name', 'stack']),
|
|
87
|
+
refImg: assertResult.refImg,
|
|
88
|
+
actualImg: assertResult.currImg
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
else if (assertResult.isUpdated) {
|
|
92
|
+
return {
|
|
93
|
+
status: constants_1.UPDATED,
|
|
94
|
+
stateName: assertResult.stateName,
|
|
95
|
+
refImg: assertResult.refImg,
|
|
96
|
+
expectedImg: lodash_1.default.clone(assertResult.refImg),
|
|
97
|
+
actualImg: assertResult.currImg
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const { currImg } = assertResult;
|
|
102
|
+
return {
|
|
103
|
+
status: constants_1.SUCCESS,
|
|
104
|
+
stateName: assertResult.stateName,
|
|
105
|
+
refImg: assertResult.refImg,
|
|
106
|
+
expectedImg: lodash_1.default.clone(assertResult.refImg),
|
|
107
|
+
...(currImg ? { actualImg: currImg } : {})
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
if (this.screenshot) {
|
|
112
|
+
imagesInfo.push({
|
|
113
|
+
status: lodash_1.default.isEmpty((0, common_utils_1.getError)(this.error)) ? constants_1.SUCCESS : constants_1.ERROR,
|
|
114
|
+
actualImg: this.screenshot
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return imagesInfo;
|
|
83
118
|
}
|
|
84
119
|
get attempt() {
|
|
85
120
|
return this._attempt;
|
|
86
121
|
}
|
|
87
|
-
set attempt(attemptNum) {
|
|
88
|
-
hermione_1.testsAttempts.set(this._testId, attemptNum);
|
|
89
|
-
this._attempt = attemptNum;
|
|
90
|
-
}
|
|
91
|
-
get assertViewResults() {
|
|
92
|
-
return this._testResult.assertViewResults || [];
|
|
93
|
-
}
|
|
94
122
|
get history() {
|
|
95
123
|
return (0, history_utils_1.getCommandsHistory)(this._testResult.history);
|
|
96
124
|
}
|
|
@@ -110,9 +138,6 @@ class HermioneTestAdapter {
|
|
|
110
138
|
get id() {
|
|
111
139
|
return this.testPath.concat(this.browserId, this.attempt.toString()).join(' ');
|
|
112
140
|
}
|
|
113
|
-
get isUpdated() {
|
|
114
|
-
return this._testResult.updated;
|
|
115
|
-
}
|
|
116
141
|
get screenshot() {
|
|
117
142
|
return lodash_1.default.get(this._testResult, 'err.screenshot');
|
|
118
143
|
}
|
|
@@ -120,30 +145,20 @@ class HermioneTestAdapter {
|
|
|
120
145
|
return this._testResult.description;
|
|
121
146
|
}
|
|
122
147
|
get meta() {
|
|
123
|
-
return this._testResult.meta;
|
|
148
|
+
return this._testResult.meta ?? {};
|
|
124
149
|
}
|
|
125
150
|
get errorDetails() {
|
|
126
151
|
if (!lodash_1.default.isNil(this._errorDetails)) {
|
|
127
152
|
return this._errorDetails;
|
|
128
153
|
}
|
|
129
|
-
|
|
130
|
-
if (details) {
|
|
131
|
-
this._errorDetails = {
|
|
132
|
-
title: details.title || 'error details',
|
|
133
|
-
data: details.data,
|
|
134
|
-
filePath: `${constants_1.ERROR_DETAILS_PATH}/${utils.getDetailsFileName(this._testResult.id, this._testResult.browserId, this.attempt)}`
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
this._errorDetails = null;
|
|
139
|
-
}
|
|
154
|
+
this._errorDetails = (0, utils_1.extractErrorDetails)(this);
|
|
140
155
|
return this._errorDetails;
|
|
141
156
|
}
|
|
142
157
|
get file() {
|
|
143
158
|
return path_1.default.relative(process.cwd(), this._testResult.file);
|
|
144
159
|
}
|
|
145
160
|
get url() {
|
|
146
|
-
return this._testResult.meta
|
|
161
|
+
return this._testResult.meta?.url;
|
|
147
162
|
}
|
|
148
163
|
get multipleTabs() {
|
|
149
164
|
return true;
|
|
@@ -156,28 +171,6 @@ class HermioneTestAdapter {
|
|
|
156
171
|
this._timestamp = timestamp;
|
|
157
172
|
}
|
|
158
173
|
}
|
|
159
|
-
async saveErrorDetails(reportPath) {
|
|
160
|
-
if (!this.errorDetails) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const detailsFilePath = path_1.default.resolve(reportPath, this.errorDetails.filePath);
|
|
164
|
-
const detailsData = lodash_1.default.isObject(this.errorDetails.data)
|
|
165
|
-
? JSON.stringify(this.errorDetails.data, null, 2)
|
|
166
|
-
: this.errorDetails.data;
|
|
167
|
-
await utils.makeDirFor(detailsFilePath);
|
|
168
|
-
await fs_extra_1.default.writeFile(detailsFilePath, detailsData);
|
|
169
|
-
}
|
|
170
|
-
decreaseAttemptNumber() {
|
|
171
|
-
const testId = (0, common_utils_1.mkTestId)(this._testResult.fullTitle(), this.browserId);
|
|
172
|
-
const currentTestAttempt = hermione_1.testsAttempts.get(testId);
|
|
173
|
-
const previousTestAttempt = currentTestAttempt - 1;
|
|
174
|
-
if (previousTestAttempt) {
|
|
175
|
-
hermione_1.testsAttempts.set(testId, previousTestAttempt);
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
hermione_1.testsAttempts.delete(testId);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
174
|
}
|
|
182
175
|
exports.HermioneTestAdapter = HermioneTestAdapter;
|
|
183
176
|
//# sourceMappingURL=hermione.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hermione.js","sourceRoot":"","sources":["../../../lib/test-adapter/hermione.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hermione.js","sourceRoot":"","sources":["../../../lib/test-adapter/hermione.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oDAAuB;AAIvB,oDAAoD;AACpD,4CAA2F;AAC3F,kDAA8G;AAiB9G,kDAA6C;AAC7C,mCAA4C;AAErC,MAAM,SAAS,GAAG,CAAC,SAAsC,EAAE,MAA0B,EAAE,UAA8B,EAAc,EAAE;IACxI,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE;QAChC,OAAO,sBAAU,CAAC,OAAO,CAAC;KAC7B;SAAM,IAAI,SAAS,KAAK,MAAM,CAAC,YAAY,EAAE;QAC1C,OAAO,sBAAU,CAAC,OAAO,CAAC;KAC7B;SAAM,IAAI,SAAS,KAAK,MAAM,CAAC,KAAK,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE;QACrE,OAAO,IAAA,8BAAe,EAAC,UAAU,CAAC,iBAAoC,CAAC,CAAC,CAAC,CAAC,sBAAU,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAU,CAAC,KAAK,CAAC;KAChH;SAAM,IAAI,SAAS,KAAK,MAAM,CAAC,UAAU,EAAE;QACxC,OAAO,sBAAU,CAAC,OAAO,CAAC;KAC7B;IACD,OAAO,sBAAU,CAAC,IAAI,CAAC;AAC3B,CAAC,CAAC;AAXW,QAAA,SAAS,aAWpB;AAEF,MAAM,cAAc,GAAG,CAAC,KAAyC,EAA6B,EAAE;IAC5F,OAAO,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,MAAM,CA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,CAAC;IAC/D,CAAC;IAED,IAAI,GAAG;QACH,OAAQ,IAAI,CAAC,WAAkC,CAAC,IAAI,EAAE,GAAyB,CAAC;IACpF,CAAC;IAED,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAI,SAAS,CAAC,SAAS;QACnB,IAAI,CAAC,gBAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;SAC/B;IACL,CAAC;CACJ;AA7KD,kDA6KC"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { TestStatus } from '../constants';
|
|
2
|
-
import {
|
|
3
|
-
export * from './hermione';
|
|
2
|
+
import { ErrorDetails, ImageBase64, ImageFile, ImageInfoFull, TestError } from '../types';
|
|
4
3
|
export interface ReporterTestResult {
|
|
5
|
-
readonly
|
|
6
|
-
attempt: number;
|
|
4
|
+
readonly attempt: number;
|
|
7
5
|
readonly browserId: string;
|
|
8
6
|
readonly description: string | undefined;
|
|
9
|
-
error: undefined | TestError;
|
|
7
|
+
readonly error: undefined | TestError;
|
|
10
8
|
readonly errorDetails: ErrorDetails | null;
|
|
11
9
|
readonly file: string;
|
|
12
10
|
readonly fullName: string;
|
|
13
11
|
readonly history: string[];
|
|
14
12
|
readonly id: string;
|
|
15
|
-
image?: boolean;
|
|
16
13
|
readonly imageDir: string;
|
|
17
|
-
readonly imagesInfo: ImageInfoFull[]
|
|
18
|
-
readonly
|
|
19
|
-
|
|
14
|
+
readonly imagesInfo: ImageInfoFull[];
|
|
15
|
+
readonly meta: {
|
|
16
|
+
browserVersion?: string;
|
|
17
|
+
} & Record<string, unknown>;
|
|
20
18
|
readonly multipleTabs: boolean;
|
|
21
|
-
readonly screenshot: ImageBase64 |
|
|
19
|
+
readonly screenshot: ImageBase64 | ImageFile | null | undefined;
|
|
22
20
|
readonly sessionId: string;
|
|
23
21
|
readonly skipReason?: string;
|
|
24
22
|
readonly state: {
|
|
@@ -1,18 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./hermione"), exports);
|
|
18
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/test-adapter/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/test-adapter/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { TestCase as PlaywrightTestCase, TestResult as PlaywrightTestResult } from '@playwright/test/reporter';
|
|
2
2
|
import { ReporterTestResult } from './index';
|
|
3
3
|
import { TestStatus } from '../constants';
|
|
4
|
-
import {
|
|
5
|
-
import { AssertViewResult, ErrorDetails, ImageData, ImageInfoFull, TestError } from '../types';
|
|
4
|
+
import { ErrorDetails, ImageFile, ImageInfoFull, TestError } from '../types';
|
|
6
5
|
import type { CoordBounds } from 'looks-same';
|
|
7
6
|
export type PlaywrightAttachment = PlaywrightTestResult['attachments'][number];
|
|
8
7
|
type ExtendedError<T> = TestError & {
|
|
@@ -30,17 +29,15 @@ export declare enum ImageTitleEnding {
|
|
|
30
29
|
Diff = "-diff.png",
|
|
31
30
|
Previous = "-previous.png"
|
|
32
31
|
}
|
|
32
|
+
export declare const DEFAULT_DIFF_OPTIONS: {
|
|
33
|
+
diffColor: string;
|
|
34
|
+
};
|
|
33
35
|
export declare const getStatus: (result: PlaywrightTestResult) => TestStatus;
|
|
34
|
-
export interface PlaywrightTestAdapterOptions {
|
|
35
|
-
imagesInfoFormatter: ImagesInfoFormatter;
|
|
36
|
-
}
|
|
37
36
|
export declare class PlaywrightTestAdapter implements ReporterTestResult {
|
|
38
37
|
private readonly _testCase;
|
|
39
38
|
private readonly _testResult;
|
|
40
39
|
private _attempt;
|
|
41
|
-
|
|
42
|
-
constructor(testCase: PlaywrightTestCase, testResult: PlaywrightTestResult, { imagesInfoFormatter }: PlaywrightTestAdapterOptions);
|
|
43
|
-
get assertViewResults(): AssertViewResult[];
|
|
40
|
+
constructor(testCase: PlaywrightTestCase, testResult: PlaywrightTestResult, attempt: number);
|
|
44
41
|
get attempt(): number;
|
|
45
42
|
get browserId(): string;
|
|
46
43
|
get description(): string | undefined;
|
|
@@ -51,11 +48,10 @@ export declare class PlaywrightTestAdapter implements ReporterTestResult {
|
|
|
51
48
|
get history(): string[];
|
|
52
49
|
get id(): string;
|
|
53
50
|
get imageDir(): string;
|
|
54
|
-
get imagesInfo(): ImageInfoFull[]
|
|
55
|
-
get isUpdated(): boolean;
|
|
51
|
+
get imagesInfo(): ImageInfoFull[];
|
|
56
52
|
get meta(): Record<string, unknown>;
|
|
57
53
|
get multipleTabs(): boolean;
|
|
58
|
-
get screenshot():
|
|
54
|
+
get screenshot(): ImageFile | null;
|
|
59
55
|
get sessionId(): string;
|
|
60
56
|
get skipReason(): string;
|
|
61
57
|
get state(): {
|
|
@@ -1,41 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.PlaywrightTestAdapter = exports.getStatus = exports.ImageTitleEnding = exports.PwtTestStatus = void 0;
|
|
6
|
+
exports.PlaywrightTestAdapter = exports.getStatus = exports.DEFAULT_DIFF_OPTIONS = exports.ImageTitleEnding = exports.PwtTestStatus = void 0;
|
|
30
7
|
const path_1 = __importDefault(require("path"));
|
|
31
8
|
const image_size_1 = __importDefault(require("image-size"));
|
|
32
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
33
10
|
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
34
|
-
const playwright_1 = require("./cache/playwright");
|
|
35
11
|
const common_utils_1 = require("../common-utils");
|
|
36
12
|
const constants_1 = require("../constants");
|
|
37
13
|
const errors_1 = require("../errors");
|
|
38
|
-
const utils = __importStar(require("../server-utils"));
|
|
39
14
|
var PwtTestStatus;
|
|
40
15
|
(function (PwtTestStatus) {
|
|
41
16
|
PwtTestStatus["PASSED"] = "passed";
|
|
@@ -52,6 +27,9 @@ var ImageTitleEnding;
|
|
|
52
27
|
ImageTitleEnding["Previous"] = "-previous.png";
|
|
53
28
|
})(ImageTitleEnding || (exports.ImageTitleEnding = ImageTitleEnding = {}));
|
|
54
29
|
const ANY_IMAGE_ENDING_REGEXP = new RegExp(Object.values(ImageTitleEnding).map(ending => `${ending}$`).join('|'));
|
|
30
|
+
exports.DEFAULT_DIFF_OPTIONS = {
|
|
31
|
+
diffColor: '#ff00ff'
|
|
32
|
+
};
|
|
55
33
|
const getStatus = (result) => {
|
|
56
34
|
if (result.status === PwtTestStatus.PASSED) {
|
|
57
35
|
return constants_1.TestStatus.SUCCESS;
|
|
@@ -80,17 +58,16 @@ const extractErrorStack = (result) => {
|
|
|
80
58
|
}
|
|
81
59
|
return JSON.stringify(result.errors.map(err => (0, strip_ansi_1.default)(err.stack || '')));
|
|
82
60
|
};
|
|
83
|
-
const
|
|
61
|
+
const extractToMatchScreenshotError = (result, { state, expectedAttachment, diffAttachment, actualAttachment }) => {
|
|
84
62
|
const snapshotName = state + '.png';
|
|
85
63
|
if (expectedAttachment && diffAttachment && actualAttachment) {
|
|
86
|
-
const errors = result.errors;
|
|
64
|
+
const errors = (result.errors || []);
|
|
87
65
|
const imageDiffError = errors.find(err => {
|
|
88
66
|
return err.meta?.type === errors_1.ErrorName.IMAGE_DIFF && err.meta.snapshotName === snapshotName;
|
|
89
67
|
});
|
|
90
68
|
return { name: errors_1.ErrorName.IMAGE_DIFF, message: '', diffClusters: imageDiffError?.meta?.diffClusters };
|
|
91
69
|
}
|
|
92
|
-
|
|
93
|
-
const errors = result.errors;
|
|
70
|
+
const errors = (result.errors || []);
|
|
94
71
|
const noRefImageError = errors.find(err => {
|
|
95
72
|
return err.meta?.type === errors_1.ErrorName.NO_REF_IMAGE && err.meta.snapshotName === snapshotName;
|
|
96
73
|
});
|
|
@@ -109,44 +86,10 @@ const getImageData = (attachment) => {
|
|
|
109
86
|
};
|
|
110
87
|
};
|
|
111
88
|
class PlaywrightTestAdapter {
|
|
112
|
-
constructor(testCase, testResult,
|
|
89
|
+
constructor(testCase, testResult, attempt) {
|
|
113
90
|
this._testCase = testCase;
|
|
114
91
|
this._testResult = testResult;
|
|
115
|
-
this.
|
|
116
|
-
const testId = (0, common_utils_1.mkTestId)(this.fullName, this.browserId);
|
|
117
|
-
if (utils.shouldUpdateAttempt(this.status)) {
|
|
118
|
-
playwright_1.testsAttempts.set(testId, lodash_1.default.isUndefined(playwright_1.testsAttempts.get(testId)) ? 0 : playwright_1.testsAttempts.get(testId) + 1);
|
|
119
|
-
}
|
|
120
|
-
this._attempt = playwright_1.testsAttempts.get(testId) || 0;
|
|
121
|
-
}
|
|
122
|
-
get assertViewResults() {
|
|
123
|
-
return Object.entries(this._attachmentsByState).map(([state, attachments]) => {
|
|
124
|
-
const expectedAttachment = attachments.find(a => a.name?.endsWith(ImageTitleEnding.Expected));
|
|
125
|
-
const diffAttachment = attachments.find(a => a.name?.endsWith(ImageTitleEnding.Diff));
|
|
126
|
-
const actualAttachment = attachments.find(a => a.name?.endsWith(ImageTitleEnding.Actual));
|
|
127
|
-
const [refImg, diffImg, currImg] = [expectedAttachment, diffAttachment, actualAttachment].map(getImageData);
|
|
128
|
-
const error = extractImageError(this._testResult, { state, expectedAttachment, diffAttachment, actualAttachment }) || this.error;
|
|
129
|
-
if (error?.name === errors_1.ErrorName.IMAGE_DIFF && refImg && diffImg && currImg) {
|
|
130
|
-
return {
|
|
131
|
-
name: errors_1.ErrorName.IMAGE_DIFF,
|
|
132
|
-
stateName: state,
|
|
133
|
-
refImg,
|
|
134
|
-
diffImg,
|
|
135
|
-
currImg,
|
|
136
|
-
diffClusters: lodash_1.default.get(error, 'diffClusters', [])
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
else if (error?.name === errors_1.ErrorName.NO_REF_IMAGE && currImg) {
|
|
140
|
-
return {
|
|
141
|
-
name: errors_1.ErrorName.NO_REF_IMAGE,
|
|
142
|
-
message: error.message,
|
|
143
|
-
stack: error.stack,
|
|
144
|
-
stateName: state,
|
|
145
|
-
currImg
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
return null;
|
|
149
|
-
}).filter(Boolean);
|
|
92
|
+
this._attempt = attempt;
|
|
150
93
|
}
|
|
151
94
|
get attempt() {
|
|
152
95
|
return this._attempt;
|
|
@@ -162,7 +105,7 @@ class PlaywrightTestAdapter {
|
|
|
162
105
|
if (message) {
|
|
163
106
|
const result = { name: errors_1.ErrorName.GENERAL_ERROR, message };
|
|
164
107
|
const stack = extractErrorStack(this._testResult);
|
|
165
|
-
if (stack) {
|
|
108
|
+
if (!lodash_1.default.isNil(stack)) {
|
|
166
109
|
result.stack = stack;
|
|
167
110
|
}
|
|
168
111
|
if (message.includes('snapshot doesn\'t exist') && message.includes('.png')) {
|
|
@@ -194,10 +137,51 @@ class PlaywrightTestAdapter {
|
|
|
194
137
|
return (0, common_utils_1.getShortMD5)(this.fullName);
|
|
195
138
|
}
|
|
196
139
|
get imagesInfo() {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
140
|
+
const imagesInfo = Object.entries(this._attachmentsByState).map(([state, attachments]) => {
|
|
141
|
+
const expectedAttachment = attachments.find(a => a.name?.endsWith(ImageTitleEnding.Expected));
|
|
142
|
+
const diffAttachment = attachments.find(a => a.name?.endsWith(ImageTitleEnding.Diff));
|
|
143
|
+
const actualAttachment = attachments.find(a => a.name?.endsWith(ImageTitleEnding.Actual));
|
|
144
|
+
const [expectedImg, diffImg, actualImg] = [expectedAttachment, diffAttachment, actualAttachment].map(getImageData);
|
|
145
|
+
const error = extractToMatchScreenshotError(this._testResult, { state, expectedAttachment, diffAttachment, actualAttachment }) || this.error;
|
|
146
|
+
// We don't provide refImg here, because on some pwt versions it's impossible to provide correct path:
|
|
147
|
+
// older pwt versions had test-results directory in expected path instead of project directory.
|
|
148
|
+
if (error?.name === errors_1.ErrorName.IMAGE_DIFF && expectedImg && diffImg && actualImg) {
|
|
149
|
+
return {
|
|
150
|
+
status: constants_1.FAIL,
|
|
151
|
+
stateName: state,
|
|
152
|
+
diffImg,
|
|
153
|
+
actualImg,
|
|
154
|
+
expectedImg,
|
|
155
|
+
diffClusters: lodash_1.default.get(error, 'diffClusters', []),
|
|
156
|
+
// TODO: extract diffOptions from config
|
|
157
|
+
diffOptions: { current: actualImg.path, reference: expectedImg.path, ...exports.DEFAULT_DIFF_OPTIONS }
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
else if (error?.name === errors_1.ErrorName.NO_REF_IMAGE && actualImg) {
|
|
161
|
+
return {
|
|
162
|
+
status: constants_1.ERROR,
|
|
163
|
+
stateName: state,
|
|
164
|
+
error: lodash_1.default.pick(error, ['message', 'name', 'stack']),
|
|
165
|
+
actualImg
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
else if (!error && expectedImg) {
|
|
169
|
+
return {
|
|
170
|
+
status: constants_1.SUCCESS,
|
|
171
|
+
stateName: state,
|
|
172
|
+
expectedImg,
|
|
173
|
+
...(actualImg ? { actualImg } : {})
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}).filter((value) => value !== null);
|
|
178
|
+
if (this.screenshot) {
|
|
179
|
+
imagesInfo.push({
|
|
180
|
+
status: lodash_1.default.isEmpty((0, common_utils_1.getError)(this.error)) ? constants_1.SUCCESS : constants_1.ERROR,
|
|
181
|
+
actualImg: this.screenshot
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return imagesInfo;
|
|
201
185
|
}
|
|
202
186
|
get meta() {
|
|
203
187
|
return Object.fromEntries(this._testCase.annotations.map(a => [a.type, a.description ?? '']));
|