@playwright/test 1.36.0-alpha-jun-27-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.
@@ -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 : [(0, _util.addSuffixToFilePath)(name, '', undefined, true)];
101
- const outputPathSegments = Array.isArray(name) ? name : [(0, _util.addSuffixToFilePath)(name, actualModifier, undefined, true)];
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 = (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');
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: (0, _util.addSuffixToFilePath)(this.snapshotName, '-actual'),
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: (0, _util.addSuffixToFilePath)(this.snapshotName, '-expected'),
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: (0, _util.addSuffixToFilePath)(this.snapshotName, '-previous'),
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: (0, _util.addSuffixToFilePath)(this.snapshotName, '-actual'),
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: (0, _util.addSuffixToFilePath)(this.snapshotName, '-diff'),
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/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(s) {
190
- return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, '-');
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-27-2023",
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-27-2023"
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("id=favorite-colors");
5577
- * await locator.selectOption(["R", "G"]);
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
  *
@@ -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 } = {}) {