@applitools/eyes-playwright 1.37.3 → 1.38.0
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/CHANGELOG.md +14 -0
- package/dist/fixture/index.js +22 -6
- package/dist/fixture/reporter.js +33 -21
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.38.0](https://github.com/Applitools-Dev/sdk/compare/js/eyes-playwright@1.37.3...js/eyes-playwright@1.38.0) (2025-07-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* canvas webgl without preserveDrawingBuffer=1 | FLD-3144 ([#3040](https://github.com/Applitools-Dev/sdk/issues/3040)) ([f82d8f1](https://github.com/Applitools-Dev/sdk/commit/f82d8f148f913098752ec7bef8635a46b453d6fa))
|
|
9
|
+
* support sharding for the eyes-playwright fixture | FLD-3026 ([#3056](https://github.com/Applitools-Dev/sdk/issues/3056)) ([96191bc](https://github.com/Applitools-Dev/sdk/commit/96191bcf8f13b5360ae5e50e13f20a6b198ff78e))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* export type Eyes from the PW fixture ([fd3a9f0](https://github.com/Applitools-Dev/sdk/commit/fd3a9f025da6023f6d500cebd2bf65d26acb5f3e))
|
|
15
|
+
* playwright worker configuration | FLD-2837 ([#3029](https://github.com/Applitools-Dev/sdk/issues/3029)) ([07014ec](https://github.com/Applitools-Dev/sdk/commit/07014ec5f3a16ed620c6ac243523cee05f02a7fd))
|
|
16
|
+
|
|
3
17
|
## [1.37.3](https://github.com/Applitools-Dev/sdk/compare/js/eyes-playwright@1.37.2...js/eyes-playwright@1.37.3) (2025-06-15)
|
|
4
18
|
|
|
5
19
|
|
package/dist/fixture/index.js
CHANGED
|
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.test = exports.expect = void 0;
|
|
27
30
|
/* eslint-disable no-console */
|
|
@@ -33,6 +36,7 @@ Object.defineProperty(exports, "expect", { enumerable: true, get: function () {
|
|
|
33
36
|
const utils = __importStar(require("@applitools/utils"));
|
|
34
37
|
const reporter_1 = require("./reporter");
|
|
35
38
|
const url_1 = require("url");
|
|
39
|
+
const path_1 = __importDefault(require("path"));
|
|
36
40
|
exports.test = test_1.test.extend({
|
|
37
41
|
eyesConfig: [{}, { option: true }],
|
|
38
42
|
eyesRunner: [
|
|
@@ -85,10 +89,20 @@ exports.test = test_1.test.extend({
|
|
|
85
89
|
],
|
|
86
90
|
closeEyesIfNeeded: [
|
|
87
91
|
async ({ page, eyesConfig, eyesRunner: runner }, use, testInfo) => {
|
|
88
|
-
|
|
92
|
+
var _a, _b, _c, _d, _e, _f;
|
|
93
|
+
const isUsingEyesReporter = testInfo.config.reporter.some(
|
|
94
|
+
// typeof testInfo.config.reporter is [string, ReporterOptions][], that's why [0] is the reporter name
|
|
95
|
+
r => r[0].includes('eyes-playwright') || r[0].includes('blob'));
|
|
96
|
+
const blobSettings = (_b = (_a = testInfo.config.reporter.find(r => r[0].includes('blob'))) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : {};
|
|
97
|
+
const blobFolder = (_d = (_c = blobSettings.outputDir) !== null && _c !== void 0 ? _c : process.env.PLAYWRIGHT_BLOB_OUTPUT_DIR) !== null && _d !== void 0 ? _d : (((_e = process.env.PLAYWRIGHT_BLOB_OUTPUT_FILE) !== null && _e !== void 0 ? _e : blobSettings.outputFile)
|
|
98
|
+
? path_1.default.basename((_f = process.env.PLAYWRIGHT_BLOB_OUTPUT_FILE) !== null && _f !== void 0 ? _f : blobSettings.outputFile)
|
|
99
|
+
: '');
|
|
89
100
|
if (isUsingEyesReporter) {
|
|
90
|
-
const
|
|
91
|
-
|
|
101
|
+
const applitoolsIdentifier = utils.general.guid();
|
|
102
|
+
// Create an identifier that will be collected by the html or reporter
|
|
103
|
+
await testInfo.attach('applitoolsIdentifier', {
|
|
104
|
+
body: `${applitoolsIdentifier}|${blobFolder}`,
|
|
105
|
+
});
|
|
92
106
|
}
|
|
93
107
|
await use();
|
|
94
108
|
const eyes = page.__eyes;
|
|
@@ -132,14 +146,16 @@ function writeResultsWhenReady({ eyes, runner, testInfo }) {
|
|
|
132
146
|
}));
|
|
133
147
|
}
|
|
134
148
|
async function getEyesConfigForWorker(workerInfo) {
|
|
135
|
-
var _a, _b, _c;
|
|
149
|
+
var _a, _b, _c, _d;
|
|
136
150
|
const { configFile } = workerInfo.config;
|
|
137
|
-
const
|
|
151
|
+
const playwrightConfigModule = configFile ? await import((0, url_1.pathToFileURL)(configFile).href) : {};
|
|
152
|
+
const playwrightConfig = ((_a = playwrightConfigModule === null || playwrightConfigModule === void 0 ? void 0 : playwrightConfigModule.use) === null || _a === void 0 ? void 0 : _a.eyesConfig) ||
|
|
153
|
+
((_c = (_b = playwrightConfigModule === null || playwrightConfigModule === void 0 ? void 0 : playwrightConfigModule.default) === null || _b === void 0 ? void 0 : _b.use) === null || _c === void 0 ? void 0 : _c.eyesConfig);
|
|
138
154
|
const projectConfig = workerInfo.project.use.eyesConfig;
|
|
139
155
|
const eyesConfig = {
|
|
140
156
|
...playwrightConfig,
|
|
141
157
|
...projectConfig,
|
|
142
158
|
};
|
|
143
|
-
(
|
|
159
|
+
(_d = eyesConfig.failTestsOnDiff) !== null && _d !== void 0 ? _d : (eyesConfig.failTestsOnDiff = process.env.CI ? 'afterAll' : 'afterEach');
|
|
144
160
|
return eyesConfig;
|
|
145
161
|
}
|
package/dist/fixture/reporter.js
CHANGED
|
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.InternalData = void 0;
|
|
27
|
-
const os = __importStar(require("os"));
|
|
28
27
|
const fs = __importStar(require("fs"));
|
|
29
28
|
const path = __importStar(require("path"));
|
|
30
29
|
const playwrightPath = require.resolve('playwright');
|
|
@@ -46,30 +45,36 @@ const createInjectedScript = (testResultsMap) => `
|
|
|
46
45
|
class EyesReporter extends HtmlReporter {
|
|
47
46
|
constructor(options) {
|
|
48
47
|
super(options);
|
|
49
|
-
this.
|
|
48
|
+
this.applitoolsIdentifiersAndFolders = [];
|
|
50
49
|
}
|
|
51
50
|
onTestEnd(test, result) {
|
|
52
51
|
var _a;
|
|
53
52
|
(_a = super.onTestEnd) === null || _a === void 0 ? void 0 : _a.call(this, test, result);
|
|
54
|
-
const index = result.attachments.findIndex(a => a.name === '
|
|
53
|
+
const index = result.attachments.findIndex(a => a.name === 'applitoolsIdentifier');
|
|
55
54
|
if (index > -1) {
|
|
56
|
-
const
|
|
57
|
-
this.
|
|
55
|
+
const applitoolsIdentifierAndFolder = result.attachments[index].body.toString();
|
|
56
|
+
this.applitoolsIdentifiersAndFolders.push(applitoolsIdentifierAndFolder);
|
|
58
57
|
this.removeInternalIdAttachment(result);
|
|
59
58
|
}
|
|
60
59
|
}
|
|
60
|
+
// TODO: let's remove this method! Removing the internal id from the test result is wrong,
|
|
61
|
+
// it should be hidden in the HTML report and the test result should be read-only.
|
|
61
62
|
removeInternalIdAttachment(result) {
|
|
62
|
-
var _a;
|
|
63
|
-
const index = result.attachments ? result.attachments.findIndex(a => a.name === '
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
const index = result.attachments ? result.attachments.findIndex(a => (a === null || a === void 0 ? void 0 : a.name) === 'applitoolsIdentifier') : -1;
|
|
64
65
|
if (index > -1)
|
|
65
66
|
(_a = result.attachments) === null || _a === void 0 ? void 0 : _a.splice(index, 1);
|
|
66
|
-
result.
|
|
67
|
+
const index2 = result.attachments ? result.attachments.findIndex(a => !a) : -1;
|
|
68
|
+
if (index2 > -1)
|
|
69
|
+
(_c = (_b = result._endPayload) === null || _b === void 0 ? void 0 : _b.attachments) === null || _c === void 0 ? void 0 : _c.splice(index2, 1);
|
|
70
|
+
if (result.steps)
|
|
71
|
+
result.steps.forEach(step => this.removeInternalIdAttachment(step));
|
|
67
72
|
}
|
|
68
73
|
async onEnd(result) {
|
|
69
74
|
await super.onEnd(result);
|
|
70
75
|
const testResultsMap = {};
|
|
71
|
-
for (const
|
|
72
|
-
const content = await exports.InternalData.consume(
|
|
76
|
+
for (const applitoolsIdentifierAndFolder of this.applitoolsIdentifiersAndFolders) {
|
|
77
|
+
const content = await exports.InternalData.consume(applitoolsIdentifierAndFolder);
|
|
73
78
|
if (content) {
|
|
74
79
|
testResultsMap[content.key] = content.data;
|
|
75
80
|
}
|
|
@@ -87,29 +92,36 @@ class EyesReporter extends HtmlReporter {
|
|
|
87
92
|
exports.default = EyesReporter;
|
|
88
93
|
exports.InternalData = {
|
|
89
94
|
async write({ testInfo, data }) {
|
|
90
|
-
const
|
|
95
|
+
const [applitoolsIdentifier, folder] = testInfo.attachments
|
|
96
|
+
.find(a => a.name === 'applitoolsIdentifier')
|
|
97
|
+
.body.toString()
|
|
98
|
+
.split('|')
|
|
99
|
+
.map(s => s.trim())
|
|
100
|
+
.filter(Boolean); // if the directory is not specified, it will be empty
|
|
91
101
|
const key = `${testInfo.testId}--${testInfo.retry}`;
|
|
92
|
-
this.ensureFolder();
|
|
93
|
-
await fs.promises.writeFile(this.getPathForInternalId(
|
|
102
|
+
this.ensureFolder(folder);
|
|
103
|
+
await fs.promises.writeFile(this.getPathForInternalId(applitoolsIdentifier, folder), JSON.stringify({ key, data }));
|
|
94
104
|
},
|
|
95
|
-
async consume(
|
|
96
|
-
const
|
|
105
|
+
async consume(applitoolsIdentifierAndFolder) {
|
|
106
|
+
const [name, folder] = applitoolsIdentifierAndFolder
|
|
107
|
+
.split('|')
|
|
108
|
+
.map(s => s.trim())
|
|
109
|
+
.filter(Boolean); // if the directory is not specified, it will be empty
|
|
110
|
+
const filepath = this.getPathForInternalId(name, folder);
|
|
97
111
|
try {
|
|
98
112
|
const content = await fs.promises.readFile(filepath, 'utf-8').then(JSON.parse);
|
|
99
|
-
await fs.promises.unlink(filepath);
|
|
100
113
|
return content;
|
|
101
114
|
}
|
|
102
115
|
catch (err) {
|
|
103
116
|
// TODO no eyes results for test - this is ok, could be that no visual tests occurred for this playwright test
|
|
104
117
|
}
|
|
105
118
|
},
|
|
106
|
-
ensureFolder() {
|
|
107
|
-
const folderPath = path.join(os.tmpdir(), 'eyes-report-files');
|
|
119
|
+
ensureFolder(folderPath = path.join('blob-report', 'eyes-report-files')) {
|
|
108
120
|
if (!fs.existsSync(folderPath)) {
|
|
109
|
-
fs.mkdirSync(folderPath);
|
|
121
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
110
122
|
}
|
|
111
123
|
},
|
|
112
|
-
getPathForInternalId(
|
|
113
|
-
return path.join(
|
|
124
|
+
getPathForInternalId(applitoolsIdentifier, folderPath = path.join('blob-report', 'eyes-report-files')) {
|
|
125
|
+
return path.join(folderPath, applitoolsIdentifier);
|
|
114
126
|
},
|
|
115
127
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/eyes-playwright",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"description": "Applitools Eyes SDK for Playwright",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eyes-playwright",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"test": "APPLITOOLS_SHOW_LOGS=true APPLITOOLS_LOG_FILE=\"./logs/$(uuidgen).log\" APPLITOOLS_BATCH_NAME='JS Tests: eyes-playwright' APPLITOOLS_BATCH_ID=$(uuidgen) run --top-level mocha './test/*.spec.{js,ts}' --exit",
|
|
55
55
|
"test:coverage": "APPLITOOLS_SHOW_LOGS=true APPLITOOLS_LOG_FILE=\"./logs/$(uuidgen).log\" APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-playwright' APPLITOOLS_BATCH_ID=$(uuidgen) MOCHA_GROUP=coverage run --top-level mocha './test/generated-coverage/*.spec.js' --parallel --jobs ${MOCHA_JOBS:-8} --exit",
|
|
56
56
|
"test:fixture": "APPLITOOLS_SHOW_LOGS=true APPLITOOLS_LOG_FILE=\"./logs/$(npx uuid).log\" APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-playwright-fixture' APPLITOOLS_BATCH_ID=$(npx uuid) run playwright test",
|
|
57
|
-
"setup": "run playwright:setup",
|
|
57
|
+
"setup": "run playwright:setup && run --top-level xvfb:setup",
|
|
58
58
|
"playwright:setup": "yarn playwright install --with-deps chromium firefox webkit",
|
|
59
59
|
"up:framework": "echo \"$(jq '.devDependencies.playwright = $ENV.APPLITOOLS_FRAMEWORK_VERSION' ./package.json)\" > ./package.json"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@applitools/eyes": "1.35.1",
|
|
63
|
-
"@applitools/spec-driver-playwright": "1.
|
|
64
|
-
"@applitools/utils": "1.
|
|
63
|
+
"@applitools/spec-driver-playwright": "1.6.0",
|
|
64
|
+
"@applitools/utils": "1.9.0",
|
|
65
65
|
"@inquirer/prompts": "7.0.1",
|
|
66
66
|
"chalk": "4.1.2",
|
|
67
67
|
"yargs": "17.7.2"
|