@o3r/testing 12.1.0-prerelease.69 → 12.1.0-prerelease.70
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/testing",
|
|
3
|
-
"version": "12.1.0-prerelease.
|
|
3
|
+
"version": "12.1.0-prerelease.70",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -94,6 +94,10 @@
|
|
|
94
94
|
"types": "./visual-test/utils.d.ts",
|
|
95
95
|
"default": "./visual-test/utils.js",
|
|
96
96
|
"import": "./esm/visual-test/utils.js"
|
|
97
|
+
},
|
|
98
|
+
"./visual-testing-reporter": {
|
|
99
|
+
"types": "./visual-testing-reporter/index.d.ts",
|
|
100
|
+
"default": "./visual-testing-reporter/index.js"
|
|
97
101
|
}
|
|
98
102
|
},
|
|
99
103
|
"peerDependencies": {
|
|
@@ -109,9 +113,9 @@
|
|
|
109
113
|
"@material/slider": "^14.0.0",
|
|
110
114
|
"@ngrx/store": "^19.0.0",
|
|
111
115
|
"@ngx-translate/core": "~16.0.4",
|
|
112
|
-
"@o3r/core": "^12.1.0-prerelease.
|
|
113
|
-
"@o3r/localization": "^12.1.0-prerelease.
|
|
114
|
-
"@o3r/schematics": "^12.1.0-prerelease.
|
|
116
|
+
"@o3r/core": "^12.1.0-prerelease.70",
|
|
117
|
+
"@o3r/localization": "^12.1.0-prerelease.70",
|
|
118
|
+
"@o3r/schematics": "^12.1.0-prerelease.70",
|
|
115
119
|
"@playwright/test": "^1.49.0",
|
|
116
120
|
"@schematics/angular": "^19.0.0",
|
|
117
121
|
"pixelmatch": "^6.0.0",
|
|
@@ -200,12 +204,12 @@
|
|
|
200
204
|
"@ngx-translate/core": "~16.0.4",
|
|
201
205
|
"@nx/eslint-plugin": "~20.4.0",
|
|
202
206
|
"@nx/jest": "~20.4.0",
|
|
203
|
-
"@o3r/build-helpers": "^12.1.0-prerelease.
|
|
204
|
-
"@o3r/core": "^12.1.0-prerelease.
|
|
205
|
-
"@o3r/eslint-plugin": "^12.1.0-prerelease.
|
|
206
|
-
"@o3r/localization": "^12.1.0-prerelease.
|
|
207
|
-
"@o3r/schematics": "^12.1.0-prerelease.
|
|
208
|
-
"@o3r/test-helpers": "^12.1.0-prerelease.
|
|
207
|
+
"@o3r/build-helpers": "^12.1.0-prerelease.70",
|
|
208
|
+
"@o3r/core": "^12.1.0-prerelease.70",
|
|
209
|
+
"@o3r/eslint-plugin": "^12.1.0-prerelease.70",
|
|
210
|
+
"@o3r/localization": "^12.1.0-prerelease.70",
|
|
211
|
+
"@o3r/schematics": "^12.1.0-prerelease.70",
|
|
212
|
+
"@o3r/test-helpers": "^12.1.0-prerelease.70",
|
|
209
213
|
"@playwright/test": "~1.50.0",
|
|
210
214
|
"@schematics/angular": "~19.1.0",
|
|
211
215
|
"@stylistic/eslint-plugin": "~3.1.0",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type FullConfig, type Reporter, type Suite } from '@playwright/test/reporter';
|
|
2
|
+
/**
|
|
3
|
+
* The screenshot information
|
|
4
|
+
*/
|
|
5
|
+
export interface ScreenshotInformation {
|
|
6
|
+
/**
|
|
7
|
+
* The path of the actual screenshot
|
|
8
|
+
*/
|
|
9
|
+
actual: string;
|
|
10
|
+
/**
|
|
11
|
+
* The path of the expected screenshot
|
|
12
|
+
*/
|
|
13
|
+
expected: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The report of the visual testing campaign
|
|
17
|
+
*/
|
|
18
|
+
export type VisualTestingReporterReport = ScreenshotInformation[];
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for the visual testing reporter
|
|
21
|
+
*/
|
|
22
|
+
export interface VisualTestingReporterOptions {
|
|
23
|
+
/** The output file for the report */
|
|
24
|
+
outputFile?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Playwright reporter for visual testing
|
|
28
|
+
*/
|
|
29
|
+
export declare class VisualTestingPlaywrightReporter implements Reporter {
|
|
30
|
+
private suite;
|
|
31
|
+
private readonly outputFile;
|
|
32
|
+
constructor(options: VisualTestingReporterOptions);
|
|
33
|
+
/**
|
|
34
|
+
* @inheritdoc
|
|
35
|
+
*/
|
|
36
|
+
printsToStdio(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @inheritdoc
|
|
39
|
+
*/
|
|
40
|
+
onBegin(_: FullConfig, suite: Suite): void;
|
|
41
|
+
/**
|
|
42
|
+
* @inheritdoc
|
|
43
|
+
*/
|
|
44
|
+
onEnd(): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export default VisualTestingPlaywrightReporter;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/visual-testing-reporter/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,KAAK,EACX,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,qBAAqB,EAAE,CAAC;AAMlE;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,+BAAgC,YAAW,QAAQ;IAC9D,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,OAAO,EAAE,4BAA4B;IAIjD;;OAEG;IACI,aAAa;IAIpB;;OAEG;IACI,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK;IAI1C;;OAEG;IACU,KAAK;CAiBnB;AAED,eAAe,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VisualTestingPlaywrightReporter = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var promises_1 = require("node:fs/promises");
|
|
6
|
+
var node_path_1 = require("node:path");
|
|
7
|
+
/**
|
|
8
|
+
* Playwright reporter for visual testing
|
|
9
|
+
*/
|
|
10
|
+
var VisualTestingPlaywrightReporter = /** @class */ (function () {
|
|
11
|
+
function VisualTestingPlaywrightReporter(options) {
|
|
12
|
+
this.outputFile = options.outputFile || (0, node_path_1.join)(process.cwd(), 'playwright-reports/visual-testing/report.json');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @inheritdoc
|
|
16
|
+
*/
|
|
17
|
+
VisualTestingPlaywrightReporter.prototype.printsToStdio = function () {
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @inheritdoc
|
|
22
|
+
*/
|
|
23
|
+
VisualTestingPlaywrightReporter.prototype.onBegin = function (_, suite) {
|
|
24
|
+
this.suite = suite;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @inheritdoc
|
|
28
|
+
*/
|
|
29
|
+
VisualTestingPlaywrightReporter.prototype.onEnd = function () {
|
|
30
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
31
|
+
var screenshotsToUpdate;
|
|
32
|
+
return tslib_1.__generator(this, function (_a) {
|
|
33
|
+
switch (_a.label) {
|
|
34
|
+
case 0:
|
|
35
|
+
screenshotsToUpdate = this.suite.allTests().flatMap(function (test) {
|
|
36
|
+
return test.results.flatMap(function (result) {
|
|
37
|
+
return result.errors
|
|
38
|
+
.map(function (error) { return error.matcherResult; })
|
|
39
|
+
.filter(function (matcherResult) {
|
|
40
|
+
return (matcherResult === null || matcherResult === void 0 ? void 0 : matcherResult.name) === 'toHaveScreenshot'
|
|
41
|
+
&& typeof matcherResult.actual === 'string'
|
|
42
|
+
&& typeof matcherResult.expected === 'string'
|
|
43
|
+
&& !matcherResult.pass;
|
|
44
|
+
})
|
|
45
|
+
.map(function (_a) {
|
|
46
|
+
var actual = _a.actual, expected = _a.expected;
|
|
47
|
+
return ({ actual: actual, expected: expected });
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return [4 /*yield*/, (0, promises_1.mkdir)((0, node_path_1.dirname)(this.outputFile), { recursive: true })];
|
|
52
|
+
case 1:
|
|
53
|
+
_a.sent();
|
|
54
|
+
return [2 /*return*/, (0, promises_1.writeFile)(this.outputFile, JSON.stringify(screenshotsToUpdate, null, 2))];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return VisualTestingPlaywrightReporter;
|
|
60
|
+
}());
|
|
61
|
+
exports.VisualTestingPlaywrightReporter = VisualTestingPlaywrightReporter;
|
|
62
|
+
exports.default = VisualTestingPlaywrightReporter;
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/visual-testing-reporter/index.ts"],"names":[],"mappings":";;;;AAAA,6CAG0B;AAC1B,uCAGmB;AAyCnB;;GAEG;AACH;IAIE,yCAAY,OAAqC;QAC/C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAA,gBAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,+CAA+C,CAAC,CAAC;IAC/G,CAAC;IAED;;OAEG;IACI,uDAAa,GAApB;QACE,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACI,iDAAO,GAAd,UAAe,CAAa,EAAE,KAAY;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;I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Type,\n} from '@playwright/test';\nimport {\n type FullConfig,\n type Reporter,\n type Suite,\n} from '@playwright/test/reporter';\n\n/**\n * The screenshot information\n */\nexport interface ScreenshotInformation {\n /**\n * The path of the actual screenshot\n */\n actual: string;\n /**\n * The path of the expected screenshot\n */\n expected: string;\n}\n\n/**\n * The report of the visual testing campaign\n */\nexport type VisualTestingReporterReport = ScreenshotInformation[];\n\ntype ScreenshotMatcherReturnType = MatcherReturnType & ScreenshotInformation & {\n name: 'toHaveScreenshot';\n};\n\n/**\n * Configuration for the visual testing reporter\n */\nexport interface VisualTestingReporterOptions {\n /** The output file for the report */\n outputFile?: string;\n}\n\n/**\n * Playwright reporter for visual testing\n */\nexport class VisualTestingPlaywrightReporter implements Reporter {\n private suite!: Suite;\n private readonly outputFile: string;\n\n constructor(options: VisualTestingReporterOptions) {\n this.outputFile = options.outputFile || join(process.cwd(), 'playwright-reports/visual-testing/report.json');\n }\n\n /**\n * @inheritdoc\n */\n public printsToStdio() {\n return false;\n }\n\n /**\n * @inheritdoc\n */\n public onBegin(_: FullConfig, suite: Suite) {\n this.suite = suite;\n }\n\n /**\n * @inheritdoc\n */\n public async onEnd() {\n const screenshotsToUpdate: VisualTestingReporterReport = this.suite.allTests().flatMap((test) =>\n test.results.flatMap((result) =>\n result.errors\n .map((error) => (error as any).matcherResult)\n .filter((matcherResult: MatcherReturnType | undefined): matcherResult is ScreenshotMatcherReturnType =>\n matcherResult?.name === 'toHaveScreenshot'\n && typeof matcherResult.actual === 'string'\n && typeof matcherResult.expected === 'string'\n && !matcherResult.pass\n )\n .map(({ actual, expected }) => ({ actual, expected }) as ScreenshotInformation)\n )\n );\n await mkdir(dirname(this.outputFile), { recursive: true });\n return writeFile(this.outputFile, JSON.stringify(screenshotsToUpdate, null, 2));\n }\n}\n\nexport default VisualTestingPlaywrightReporter;\n"]}
|