@playwright/test 1.36.0-alpha-jun-26-2023 → 1.36.0-alpha-jun-28-2023
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 +21 -11
- package/lib/runner/uiMode.js +11 -10
- package/lib/util.js +10 -10
- package/package.json +2 -2
- package/types/test.d.ts +3 -3
- package/types/testReporter.d.ts +1 -1
|
@@ -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 : [
|
|
101
|
-
const outputPathSegments = Array.isArray(name) ? name : [
|
|
100
|
+
const inputPathSegments = Array.isArray(name) ? name : [addSuffixToFilePath(name, '', undefined, true)];
|
|
101
|
+
const outputPathSegments = Array.isArray(name) ? name : [addSuffixToFilePath(name, actualModifier, undefined, true)];
|
|
102
102
|
this.snapshotPath = snapshotPathResolver(...inputPathSegments);
|
|
103
103
|
const inputFile = testInfo.outputPath(...inputPathSegments);
|
|
104
104
|
const outputFile = testInfo.outputPath(...outputPathSegments);
|
|
105
|
-
this.expectedPath =
|
|
106
|
-
this.previousPath =
|
|
107
|
-
this.actualPath =
|
|
108
|
-
this.diffPath =
|
|
105
|
+
this.expectedPath = addSuffixToFilePath(inputFile, '-expected');
|
|
106
|
+
this.previousPath = addSuffixToFilePath(outputFile, '-previous');
|
|
107
|
+
this.actualPath = addSuffixToFilePath(outputFile, '-actual');
|
|
108
|
+
this.diffPath = 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:
|
|
153
|
+
name: 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:
|
|
186
|
+
name: 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:
|
|
195
|
+
name: 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:
|
|
204
|
+
name: 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:
|
|
213
|
+
name: addSuffixToFilePath(this.snapshotName, '-diff'),
|
|
214
214
|
contentType: this.mimeType,
|
|
215
215
|
path: this.diffPath
|
|
216
216
|
});
|
|
@@ -399,4 +399,14 @@ 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);
|
|
402
412
|
}
|
package/lib/runner/uiMode.js
CHANGED
|
@@ -89,15 +89,10 @@ class UIMode {
|
|
|
89
89
|
return status;
|
|
90
90
|
}
|
|
91
91
|
async showUI(options) {
|
|
92
|
-
const exitPromise = new _utils.ManualPromise();
|
|
93
92
|
let queue = Promise.resolve();
|
|
94
93
|
this._transport = {
|
|
95
94
|
dispatch: async (method, params) => {
|
|
96
95
|
if (method === 'ping') return;
|
|
97
|
-
if (method === 'exit') {
|
|
98
|
-
exitPromise.resolve();
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
96
|
if (method === 'watch') {
|
|
102
97
|
this._watchFiles(params.fileNames);
|
|
103
98
|
return;
|
|
@@ -120,16 +115,22 @@ class UIMode {
|
|
|
120
115
|
queue = queue.then(() => this._queueListOrRun(method, params));
|
|
121
116
|
await queue;
|
|
122
117
|
},
|
|
123
|
-
onclose: () =>
|
|
118
|
+
onclose: () => {}
|
|
124
119
|
};
|
|
125
|
-
|
|
120
|
+
const openOptions = {
|
|
126
121
|
app: 'uiMode.html',
|
|
127
122
|
headless: (0, _utils.isUnderTest)() && process.env.PWTEST_HEADED_FOR_TEST !== '1',
|
|
128
123
|
transport: this._transport,
|
|
129
124
|
host: options.host,
|
|
130
|
-
port: options.port
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
port: options.port
|
|
126
|
+
};
|
|
127
|
+
const exitPromise = new _utils.ManualPromise();
|
|
128
|
+
if (options.host !== undefined || options.port !== undefined) {
|
|
129
|
+
await (0, _server.openTraceInBrowser)([], openOptions);
|
|
130
|
+
} else {
|
|
131
|
+
const page = await (0, _server.openTraceViewerApp)([], 'chromium', openOptions);
|
|
132
|
+
page.on('close', () => exitPromise.resolve());
|
|
133
|
+
}
|
|
133
134
|
if (!process.env.PWTEST_DEBUG) {
|
|
134
135
|
process.stdout.write = chunk => {
|
|
135
136
|
this._dispatchEvent('stdio', chunkToPayload('stdout', chunk));
|
package/lib/util.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.addSuffixToFilePath = addSuffixToFilePath;
|
|
7
6
|
exports.callLogText = callLogText;
|
|
8
7
|
exports.createFileFiltersFromArguments = createFileFiltersFromArguments;
|
|
9
8
|
exports.createFileMatcher = createFileMatcher;
|
|
@@ -186,8 +185,16 @@ function expectTypes(receiver, types, matcherName) {
|
|
|
186
185
|
throw new Error(`${matcherName} can be only used with ${typesString} object${types.length > 1 ? 's' : ''}`);
|
|
187
186
|
}
|
|
188
187
|
}
|
|
189
|
-
function sanitizeForFilePath(
|
|
190
|
-
|
|
188
|
+
function sanitizeForFilePath(input) {
|
|
189
|
+
let nonTrivialSubstitute = false;
|
|
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);
|
|
191
198
|
}
|
|
192
199
|
function trimLongString(s, length = 100) {
|
|
193
200
|
if (s.length <= length) return s;
|
|
@@ -197,13 +204,6 @@ function trimLongString(s, length = 100) {
|
|
|
197
204
|
const end = length - middle.length - start;
|
|
198
205
|
return s.substring(0, start) + middle + s.slice(-end);
|
|
199
206
|
}
|
|
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.0-alpha-jun-
|
|
3
|
+
"version": "1.36.0-alpha-jun-28-2023",
|
|
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.0-alpha-jun-
|
|
44
|
+
"playwright-core": "1.36.0-alpha-jun-28-2023"
|
|
45
45
|
},
|
|
46
46
|
"optionalDependencies": {
|
|
47
47
|
"fsevents": "2.3.2"
|
package/types/test.d.ts
CHANGED
|
@@ -3322,7 +3322,7 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
|
|
|
3322
3322
|
* ```js
|
|
3323
3323
|
* // playwright.config.ts
|
|
3324
3324
|
* import { defineConfig } from '@playwright/test';
|
|
3325
|
-
* import { Options } from './my-test';
|
|
3325
|
+
* import type { Options } from './my-test';
|
|
3326
3326
|
*
|
|
3327
3327
|
* export default defineConfig<Options>({
|
|
3328
3328
|
* projects: [
|
|
@@ -5573,8 +5573,8 @@ interface LocatorAssertions {
|
|
|
5573
5573
|
* ```
|
|
5574
5574
|
*
|
|
5575
5575
|
* ```js
|
|
5576
|
-
* const locator = page.locator(
|
|
5577
|
-
* await locator.selectOption([
|
|
5576
|
+
* const locator = page.locator('id=favorite-colors');
|
|
5577
|
+
* await locator.selectOption(['R', 'G']);
|
|
5578
5578
|
* await expect(locator).toHaveValues([/R/, /G/]);
|
|
5579
5579
|
* ```
|
|
5580
5580
|
*
|
package/types/testReporter.d.ts
CHANGED
|
@@ -316,7 +316,7 @@ export interface FullResult {
|
|
|
316
316
|
*
|
|
317
317
|
* ```js
|
|
318
318
|
* // my-awesome-reporter.ts
|
|
319
|
-
* import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
|
319
|
+
* import type { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
|
320
320
|
*
|
|
321
321
|
* class MyReporter implements Reporter {
|
|
322
322
|
* constructor(options: { customOption?: string } = {}) {
|