@playwright/test 1.36.0 → 1.36.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/lib/matchers/toMatchSnapshot.js +11 -21
- package/lib/util.js +10 -10
- package/package.json +2 -2
|
@@ -97,15 +97,15 @@ class SnapshotHelper {
|
|
|
97
97
|
if (options.maxDiffPixelRatio !== undefined && (options.maxDiffPixelRatio < 0 || options.maxDiffPixelRatio > 1)) throw new Error('`maxDiffPixelRatio` option value must be between 0 and 1');
|
|
98
98
|
|
|
99
99
|
// sanitizes path if string
|
|
100
|
-
const inputPathSegments = Array.isArray(name) ? name : [addSuffixToFilePath(name, '', undefined, true)];
|
|
101
|
-
const outputPathSegments = Array.isArray(name) ? name : [addSuffixToFilePath(name, actualModifier, undefined, true)];
|
|
100
|
+
const inputPathSegments = Array.isArray(name) ? name : [(0, _util.addSuffixToFilePath)(name, '', undefined, true)];
|
|
101
|
+
const outputPathSegments = Array.isArray(name) ? name : [(0, _util.addSuffixToFilePath)(name, actualModifier, undefined, true)];
|
|
102
102
|
this.snapshotPath = snapshotPathResolver(...inputPathSegments);
|
|
103
103
|
const inputFile = testInfo._getOutputPath(...inputPathSegments);
|
|
104
104
|
const outputFile = testInfo._getOutputPath(...outputPathSegments);
|
|
105
|
-
this.expectedPath = addSuffixToFilePath(inputFile, '-expected');
|
|
106
|
-
this.previousPath = addSuffixToFilePath(outputFile, '-previous');
|
|
107
|
-
this.actualPath = addSuffixToFilePath(outputFile, '-actual');
|
|
108
|
-
this.diffPath = addSuffixToFilePath(outputFile, '-diff');
|
|
105
|
+
this.expectedPath = (0, _util.addSuffixToFilePath)(inputFile, '-expected');
|
|
106
|
+
this.previousPath = (0, _util.addSuffixToFilePath)(outputFile, '-previous');
|
|
107
|
+
this.actualPath = (0, _util.addSuffixToFilePath)(outputFile, '-actual');
|
|
108
|
+
this.diffPath = (0, _util.addSuffixToFilePath)(outputFile, '-diff');
|
|
109
109
|
this.updateSnapshots = testInfo.config.updateSnapshots;
|
|
110
110
|
if (this.updateSnapshots === 'missing' && testInfo.retry < testInfo.project.retries) this.updateSnapshots = 'none';
|
|
111
111
|
this.mimeType = (_mime$getType = _utilsBundle.mime.getType(_path.default.basename(this.snapshotPath))) !== null && _mime$getType !== void 0 ? _mime$getType : 'application/octet-string';
|
|
@@ -150,7 +150,7 @@ class SnapshotHelper {
|
|
|
150
150
|
writeFileSync(this.snapshotPath, actual);
|
|
151
151
|
writeFileSync(this.actualPath, actual);
|
|
152
152
|
this.testInfo.attachments.push({
|
|
153
|
-
name: addSuffixToFilePath(this.snapshotName, '-actual'),
|
|
153
|
+
name: (0, _util.addSuffixToFilePath)(this.snapshotName, '-actual'),
|
|
154
154
|
contentType: this.mimeType,
|
|
155
155
|
path: this.actualPath
|
|
156
156
|
});
|
|
@@ -183,7 +183,7 @@ class SnapshotHelper {
|
|
|
183
183
|
if (expected !== undefined) {
|
|
184
184
|
writeFileSync(this.expectedPath, expected);
|
|
185
185
|
this.testInfo.attachments.push({
|
|
186
|
-
name: addSuffixToFilePath(this.snapshotName, '-expected'),
|
|
186
|
+
name: (0, _util.addSuffixToFilePath)(this.snapshotName, '-expected'),
|
|
187
187
|
contentType: this.mimeType,
|
|
188
188
|
path: this.expectedPath
|
|
189
189
|
});
|
|
@@ -192,7 +192,7 @@ class SnapshotHelper {
|
|
|
192
192
|
if (previous !== undefined) {
|
|
193
193
|
writeFileSync(this.previousPath, previous);
|
|
194
194
|
this.testInfo.attachments.push({
|
|
195
|
-
name: addSuffixToFilePath(this.snapshotName, '-previous'),
|
|
195
|
+
name: (0, _util.addSuffixToFilePath)(this.snapshotName, '-previous'),
|
|
196
196
|
contentType: this.mimeType,
|
|
197
197
|
path: this.previousPath
|
|
198
198
|
});
|
|
@@ -201,7 +201,7 @@ class SnapshotHelper {
|
|
|
201
201
|
if (actual !== undefined) {
|
|
202
202
|
writeFileSync(this.actualPath, actual);
|
|
203
203
|
this.testInfo.attachments.push({
|
|
204
|
-
name: addSuffixToFilePath(this.snapshotName, '-actual'),
|
|
204
|
+
name: (0, _util.addSuffixToFilePath)(this.snapshotName, '-actual'),
|
|
205
205
|
contentType: this.mimeType,
|
|
206
206
|
path: this.actualPath
|
|
207
207
|
});
|
|
@@ -210,7 +210,7 @@ class SnapshotHelper {
|
|
|
210
210
|
if (diff !== undefined) {
|
|
211
211
|
writeFileSync(this.diffPath, diff);
|
|
212
212
|
this.testInfo.attachments.push({
|
|
213
|
-
name: addSuffixToFilePath(this.snapshotName, '-diff'),
|
|
213
|
+
name: (0, _util.addSuffixToFilePath)(this.snapshotName, '-diff'),
|
|
214
214
|
contentType: this.mimeType,
|
|
215
215
|
path: this.diffPath
|
|
216
216
|
});
|
|
@@ -399,14 +399,4 @@ function determineFileExtension(file) {
|
|
|
399
399
|
}
|
|
400
400
|
function compareMagicBytes(file, magicBytes) {
|
|
401
401
|
return Buffer.compare(Buffer.from(magicBytes), file.slice(0, magicBytes.length)) === 0;
|
|
402
|
-
}
|
|
403
|
-
function addSuffixToFilePath(filePath, suffix, customExtension, sanitize = false) {
|
|
404
|
-
const dirname = _path.default.dirname(filePath);
|
|
405
|
-
const ext = _path.default.extname(filePath);
|
|
406
|
-
const name = _path.default.basename(filePath, ext);
|
|
407
|
-
const base = _path.default.join(dirname, name);
|
|
408
|
-
const sanitizeForSnapshotFilePath = s => {
|
|
409
|
-
return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
|
|
410
|
-
};
|
|
411
|
-
return (sanitize ? sanitizeForSnapshotFilePath(base) : base) + suffix + (customExtension || ext);
|
|
412
402
|
}
|
package/lib/util.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.addSuffixToFilePath = addSuffixToFilePath;
|
|
6
7
|
exports.callLogText = callLogText;
|
|
7
8
|
exports.createFileFiltersFromArguments = createFileFiltersFromArguments;
|
|
8
9
|
exports.createFileMatcher = createFileMatcher;
|
|
@@ -185,16 +186,8 @@ function expectTypes(receiver, types, matcherName) {
|
|
|
185
186
|
throw new Error(`${matcherName} can be only used with ${typesString} object${types.length > 1 ? 's' : ''}`);
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
|
-
function sanitizeForFilePath(
|
|
189
|
-
|
|
190
|
-
let sanitized = input.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F\x2A\-\*]+/g, substring => {
|
|
191
|
-
if (substring !== ' ') nonTrivialSubstitute = true;
|
|
192
|
-
return '-';
|
|
193
|
-
});
|
|
194
|
-
if (!nonTrivialSubstitute) return sanitized;
|
|
195
|
-
// If we sanitized the beginning or end, remove it for cosmetic reasons.
|
|
196
|
-
sanitized = sanitized.replace(/^-/, '').replace(/-$/, '');
|
|
197
|
-
return sanitized + '-' + (0, _utils.calculateSha1)(input).substring(0, 6);
|
|
189
|
+
function sanitizeForFilePath(s) {
|
|
190
|
+
return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
|
|
198
191
|
}
|
|
199
192
|
function trimLongString(s, length = 100) {
|
|
200
193
|
if (s.length <= length) return s;
|
|
@@ -204,6 +197,13 @@ function trimLongString(s, length = 100) {
|
|
|
204
197
|
const end = length - middle.length - start;
|
|
205
198
|
return s.substring(0, start) + middle + s.slice(-end);
|
|
206
199
|
}
|
|
200
|
+
function addSuffixToFilePath(filePath, suffix, customExtension, sanitize = false) {
|
|
201
|
+
const dirname = _path.default.dirname(filePath);
|
|
202
|
+
const ext = _path.default.extname(filePath);
|
|
203
|
+
const name = _path.default.basename(filePath, ext);
|
|
204
|
+
const base = _path.default.join(dirname, name);
|
|
205
|
+
return (sanitize ? sanitizeForFilePath(base) : base) + suffix + (customExtension || ext);
|
|
206
|
+
}
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
209
|
* Returns absolute path contained within parent directory.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playwright/test",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.1",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": "github:Microsoft/playwright",
|
|
6
6
|
"homepage": "https://playwright.dev",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"license": "Apache-2.0",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@types/node": "*",
|
|
44
|
-
"playwright-core": "1.36.
|
|
44
|
+
"playwright-core": "1.36.1"
|
|
45
45
|
},
|
|
46
46
|
"optionalDependencies": {
|
|
47
47
|
"fsevents": "2.3.2"
|