playwright 1.38.0 → 1.38.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.
@@ -107,4 +107,7 @@ class ListModeReporter extends _empty.default {
107
107
  // eslint-disable-next-line no-console
108
108
  console.error('\n' + (0, _base.formatError)(error, false).message);
109
109
  }
110
+ printsToStdio() {
111
+ return true;
112
+ }
110
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright",
3
- "version": "1.38.0",
3
+ "version": "1.38.1",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": "github:Microsoft/playwright",
6
6
  "homepage": "https://playwright.dev",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "license": "Apache-2.0",
53
53
  "dependencies": {
54
- "playwright-core": "1.38.0"
54
+ "playwright-core": "1.38.1"
55
55
  },
56
56
  "optionalDependencies": {
57
57
  "fsevents": "2.3.2"
package/types/test.d.ts CHANGED
@@ -595,8 +595,7 @@ interface TestConfig {
595
595
  };
596
596
 
597
597
  /**
598
- * Configuration for the `expect` assertion library. Learn more about
599
- * [test configuration](https://playwright.dev/docs/test-configuration#expect-options).
598
+ * Configuration for the `expect` assertion library. Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts).
600
599
  *
601
600
  * **Usage**
602
601
  *
@@ -607,7 +606,7 @@ interface TestConfig {
607
606
  * export default defineConfig({
608
607
  * expect: {
609
608
  * timeout: 10000,
610
- * toHaveScreenshot: {
609
+ * toMatchSnapshot: {
611
610
  * maxDiffPixels: 10,
612
611
  * },
613
612
  * },
@@ -628,19 +627,19 @@ interface TestConfig {
628
627
  */
629
628
  toHaveScreenshot?: {
630
629
  /**
631
- * An acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and
630
+ * an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and
632
631
  * `1` (lax). `"pixelmatch"` comparator computes color difference in
633
632
  * [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`.
634
633
  */
635
634
  threshold?: number;
636
635
 
637
636
  /**
638
- * An acceptable amount of pixels that could be different, unset by default.
637
+ * an acceptable amount of pixels that could be different, unset by default.
639
638
  */
640
639
  maxDiffPixels?: number;
641
640
 
642
641
  /**
643
- * An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by
642
+ * an acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by
644
643
  * default.
645
644
  */
646
645
  maxDiffPixelRatio?: number;
@@ -666,25 +665,25 @@ interface TestConfig {
666
665
 
667
666
  /**
668
667
  * Configuration for the
669
- * [snapshotAssertions.toMatchSnapshot(name)](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
668
+ * [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
670
669
  * method.
671
670
  */
672
671
  toMatchSnapshot?: {
673
672
  /**
674
- * **Deprecated.** An acceptable perceived color difference between the same pixel in compared images, ranging from
675
- * `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in
673
+ * an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and
674
+ * `1` (lax). `"pixelmatch"` comparator computes color difference in
676
675
  * [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`.
677
676
  */
678
677
  threshold?: number;
679
678
 
680
679
  /**
681
- * **Deprecated.** An acceptable amount of pixels that could be different, unset by default.
680
+ * an acceptable amount of pixels that could be different, unset by default.
682
681
  */
683
682
  maxDiffPixels?: number;
684
683
 
685
684
  /**
686
- * **Deprecated.** An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1`
687
- * , unset by default.
685
+ * an acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by
686
+ * default.
688
687
  */
689
688
  maxDiffPixelRatio?: number;
690
689
  };
@@ -834,10 +833,8 @@ interface TestConfig {
834
833
  grepInvert?: RegExp|Array<RegExp>;
835
834
 
836
835
  /**
837
- * Whether to skip snapshot expectations, such as
838
- * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
839
- * and
840
- * [snapshotAssertions.toMatchSnapshot(name)](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
836
+ * Whether to skip snapshot expectations, such as `expect(value).toMatchSnapshot()` and `await
837
+ * expect(page).toHaveScreenshot()`.
841
838
  *
842
839
  * **Usage**
843
840
  *
@@ -1106,9 +1103,8 @@ interface TestConfig {
1106
1103
  * [testConfig.snapshotPathTemplate](https://playwright.dev/docs/api/class-testconfig#test-config-snapshot-path-template)
1107
1104
  * to configure snapshot paths.
1108
1105
  *
1109
- * The base directory, relative to the config file, for screenshot files created with
1110
- * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1).
1111
- * Defaults to [testConfig.testDir](https://playwright.dev/docs/api/class-testconfig#test-config-test-dir).
1106
+ * The base directory, relative to the config file, for snapshot files created with `toMatchSnapshot`. Defaults to
1107
+ * [testConfig.testDir](https://playwright.dev/docs/api/class-testconfig#test-config-test-dir).
1112
1108
  *
1113
1109
  * **Usage**
1114
1110
  *
@@ -1137,7 +1133,7 @@ interface TestConfig {
1137
1133
  * This option configures a template controlling location of snapshots generated by
1138
1134
  * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
1139
1135
  * and
1140
- * [snapshotAssertions.toMatchSnapshot(name)](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
1136
+ * [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
1141
1137
  *
1142
1138
  * **Usage**
1143
1139
  *
@@ -2271,8 +2267,8 @@ export interface TestInfo {
2271
2267
  *
2272
2268
  * Suffix used to differentiate snapshots between multiple test configurations. For example, if snapshots depend on
2273
2269
  * the platform, you can set `testInfo.snapshotSuffix` equal to `process.platform`. In this case
2274
- * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
2275
- * will use different snapshots depending on the platform. Learn more about [snapshots](https://playwright.dev/docs/test-snapshots).
2270
+ * `expect(value).toMatchSnapshot(snapshotName)` will use different snapshots depending on the platform. Learn more
2271
+ * about [snapshots](https://playwright.dev/docs/test-snapshots).
2276
2272
  */
2277
2273
  snapshotSuffix: string;
2278
2274
 
@@ -5075,35 +5071,13 @@ type FunctionAssertions = {
5075
5071
  toPass(options?: { timeout?: number, intervals?: number[] }): Promise<void>;
5076
5072
  };
5077
5073
 
5078
- type BufferAssertions = {
5079
- /**
5080
- * Ensures that the passed [Buffer] matches the expected snapshot stored in the test snapshots directory.
5081
- * @deprecated To avoid flakiness, use
5082
- * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
5083
- * instead.
5084
- * @param name Snapshot name.
5085
- * @param options
5086
- */
5087
- toMatchSnapshot(name: string | Array<string>, options?: { maxDiffPixelRatio?: number, maxDiffPixels?: number, threshold?: number }): void;
5088
-
5089
- /**
5090
- * Ensures that the passed [Buffer] matches the expected snapshot stored in the test snapshots directory.
5091
- * @deprecated To avoid flakiness, use
5092
- * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
5093
- * instead.
5094
- * @param options
5095
- */
5096
- toMatchSnapshot(options?: { maxDiffPixelRatio?: number, maxDiffPixels?: number, name?: string|Array<string>, threshold?: number }): void;
5097
- };
5098
-
5099
5074
  type BaseMatchers<R, T> = GenericAssertions<R> & PlaywrightTest.Matchers<R, T> & SnapshotAssertions;
5100
- type AllowedGenericMatchers<R> = Pick<GenericAssertions<R>, 'toBe' | 'toBeDefined' | 'toBeFalsy' | 'toBeNull' | 'toBeTruthy' | 'toBeUndefined'>;
5075
+ type AllowedGenericMatchers<R, T> = PlaywrightTest.Matchers<R, T> & Pick<GenericAssertions<R>, 'toBe' | 'toBeDefined' | 'toBeFalsy' | 'toBeNull' | 'toBeTruthy' | 'toBeUndefined'>;
5101
5076
 
5102
5077
  type SpecificMatchers<R, T> =
5103
- T extends Page ? PageAssertions & AllowedGenericMatchers<R> :
5104
- T extends Locator ? LocatorAssertions & AllowedGenericMatchers<R> :
5105
- T extends APIResponse ? APIResponseAssertions & AllowedGenericMatchers<R> :
5106
- T extends Buffer ? BufferAssertions & GenericAssertions<R> & PlaywrightTest.Matchers<R, T> :
5078
+ T extends Page ? PageAssertions & AllowedGenericMatchers<R, T> :
5079
+ T extends Locator ? LocatorAssertions & AllowedGenericMatchers<R, T> :
5080
+ T extends APIResponse ? APIResponseAssertions & AllowedGenericMatchers<R, T> :
5107
5081
  BaseMatchers<R, T> & (T extends Function ? FunctionAssertions : {});
5108
5082
  type AllMatchers<R, T> = PageAssertions & LocatorAssertions & APIResponseAssertions & FunctionAssertions & BaseMatchers<R, T>;
5109
5083
 
@@ -6247,63 +6221,123 @@ interface PageAssertions {
6247
6221
  }
6248
6222
 
6249
6223
  /**
6250
- * **NOTE** For visual regression testing, use
6251
- * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
6252
- * and
6253
- * [locatorAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-screenshot-1)
6254
- * instead.
6255
- *
6256
- * Playwright provides methods for comparing text values with expected values stored in snapshot files.
6224
+ * Playwright provides methods for comparing page and element screenshots with expected values stored in files.
6257
6225
  *
6258
6226
  * ```js
6259
- * expect(text).toMatchSnapshot('snapshot.txt');
6227
+ * expect(screenshot).toMatchSnapshot('landing-page.png');
6260
6228
  * ```
6261
6229
  *
6262
6230
  */
6263
6231
  interface SnapshotAssertions {
6264
6232
  /**
6265
- * Ensures that the passed [string] matches the expected snapshot stored in the test snapshots directory.
6233
+ * **NOTE** To compare screenshots, use
6234
+ * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
6235
+ * instead.
6236
+ *
6237
+ * Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test
6238
+ * snapshots directory.
6266
6239
  *
6267
6240
  * **Usage**
6268
6241
  *
6269
6242
  * ```js
6270
6243
  * // Basic usage.
6271
- * expect(await page.title()).toMatchSnapshot('page-title.txt');
6244
+ * expect(await page.screenshot()).toMatchSnapshot('landing-page.png');
6245
+ *
6246
+ * // Pass options to customize the snapshot comparison and have a generated name.
6247
+ * expect(await page.screenshot()).toMatchSnapshot('landing-page.png', {
6248
+ * maxDiffPixels: 27, // allow no more than 27 different pixels.
6249
+ * });
6250
+ *
6251
+ * // Configure image matching threshold.
6252
+ * expect(await page.screenshot()).toMatchSnapshot('landing-page.png', { threshold: 0.3 });
6272
6253
  *
6273
6254
  * // Bring some structure to your snapshot files by passing file path segments.
6274
- * expect(await page.title()).toMatchSnapshot(['page-title', 'step1.txt']);
6275
- * expect(await page.title()).toMatchSnapshot(['page-title', 'step2.txt']);
6255
+ * expect(await page.screenshot()).toMatchSnapshot(['landing', 'step2.png']);
6256
+ * expect(await page.screenshot()).toMatchSnapshot(['landing', 'step3.png']);
6276
6257
  * ```
6277
6258
  *
6259
+ * Learn more about [visual comparisons](https://playwright.dev/docs/test-snapshots).
6260
+ *
6278
6261
  * Note that matching snapshots only work with Playwright test runner.
6279
6262
  * @param name Snapshot name.
6263
+ * @param options
6280
6264
  */
6281
- toMatchSnapshot(name: string|Array<string>): void;
6265
+ toMatchSnapshot(name: string|Array<string>, options?: {
6266
+ /**
6267
+ * An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1`. Default is
6268
+ * configurable with `TestConfig.expect`. Unset by default.
6269
+ */
6270
+ maxDiffPixelRatio?: number;
6271
+
6272
+ /**
6273
+ * An acceptable amount of pixels that could be different. Default is configurable with `TestConfig.expect`. Unset by
6274
+ * default.
6275
+ */
6276
+ maxDiffPixels?: number;
6277
+
6278
+ /**
6279
+ * An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the
6280
+ * same pixel in compared images, between zero (strict) and one (lax), default is configurable with
6281
+ * `TestConfig.expect`. Defaults to `0.2`.
6282
+ */
6283
+ threshold?: number;
6284
+ }): void;
6282
6285
 
6283
6286
  /**
6287
+ * **NOTE** To compare screenshots, use
6288
+ * [pageAssertions.toHaveScreenshot([options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-2)
6289
+ * instead.
6290
+ *
6284
6291
  * Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test
6285
6292
  * snapshots directory.
6286
6293
  *
6287
6294
  * **Usage**
6288
6295
  *
6289
6296
  * ```js
6290
- * // Basic usage.
6291
- * expect(await page.title()).toMatchSnapshot();
6297
+ * // Basic usage and the file name is derived from the test name.
6298
+ * expect(await page.screenshot()).toMatchSnapshot();
6292
6299
  *
6293
- * // Configure the snapshot name.
6294
- * expect(await page.title()).toMatchSnapshot({
6295
- * name: 'page-title.txt',
6300
+ * // Pass options to customize the snapshot comparison and have a generated name.
6301
+ * expect(await page.screenshot()).toMatchSnapshot({
6302
+ * maxDiffPixels: 27, // allow no more than 27 different pixels.
6303
+ * });
6304
+ *
6305
+ * // Configure image matching threshold and snapshot name.
6306
+ * expect(await page.screenshot()).toMatchSnapshot({
6307
+ * name: 'landing-page.png',
6308
+ * threshold: 0.3,
6296
6309
  * });
6297
6310
  * ```
6298
6311
  *
6312
+ * Learn more about [visual comparisons](https://playwright.dev/docs/test-snapshots).
6313
+ *
6299
6314
  * Note that matching snapshots only work with Playwright test runner.
6300
6315
  * @param options
6301
6316
  */
6302
6317
  toMatchSnapshot(options?: {
6318
+ /**
6319
+ * An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1`. Default is
6320
+ * configurable with `TestConfig.expect`. Unset by default.
6321
+ */
6322
+ maxDiffPixelRatio?: number;
6323
+
6324
+ /**
6325
+ * An acceptable amount of pixels that could be different. Default is configurable with `TestConfig.expect`. Unset by
6326
+ * default.
6327
+ */
6328
+ maxDiffPixels?: number;
6329
+
6303
6330
  /**
6304
6331
  * Snapshot name. If not passed, the test name and ordinals are used when called multiple times.
6305
6332
  */
6306
6333
  name?: string|Array<string>;
6334
+
6335
+ /**
6336
+ * An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the
6337
+ * same pixel in compared images, between zero (strict) and one (lax), default is configurable with
6338
+ * `TestConfig.expect`. Defaults to `0.2`.
6339
+ */
6340
+ threshold?: number;
6307
6341
  }): void;
6308
6342
  }
6309
6343
 
@@ -6439,19 +6473,19 @@ interface TestProject {
6439
6473
  */
6440
6474
  toHaveScreenshot?: {
6441
6475
  /**
6442
- * An acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and
6476
+ * an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and
6443
6477
  * `1` (lax). `"pixelmatch"` comparator computes color difference in
6444
6478
  * [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`.
6445
6479
  */
6446
6480
  threshold?: number;
6447
6481
 
6448
6482
  /**
6449
- * An acceptable amount of pixels that could be different, unset by default.
6483
+ * an acceptable amount of pixels that could be different, unset by default.
6450
6484
  */
6451
6485
  maxDiffPixels?: number;
6452
6486
 
6453
6487
  /**
6454
- * An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by
6488
+ * an acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by
6455
6489
  * default.
6456
6490
  */
6457
6491
  maxDiffPixelRatio?: number;
@@ -6477,25 +6511,25 @@ interface TestProject {
6477
6511
 
6478
6512
  /**
6479
6513
  * Configuration for the
6480
- * [snapshotAssertions.toMatchSnapshot(name)](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
6514
+ * [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
6481
6515
  * method.
6482
6516
  */
6483
6517
  toMatchSnapshot?: {
6484
6518
  /**
6485
- * **Deprecated.** An acceptable perceived color difference between the same pixel in compared images, ranging from
6486
- * `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in
6519
+ * an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and
6520
+ * `1` (lax). `"pixelmatch"` comparator computes color difference in
6487
6521
  * [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`.
6488
6522
  */
6489
6523
  threshold?: number;
6490
6524
 
6491
6525
  /**
6492
- * **Deprecated.** An acceptable amount of pixels that could be different, unset by default.
6526
+ * an acceptable amount of pixels that could be different, unset by default.
6493
6527
  */
6494
6528
  maxDiffPixels?: number;
6495
6529
 
6496
6530
  /**
6497
- * **Deprecated.** An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1`
6498
- * , unset by default.
6531
+ * an acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by
6532
+ * default.
6499
6533
  */
6500
6534
  maxDiffPixelRatio?: number;
6501
6535
  };
@@ -6605,7 +6639,7 @@ interface TestProject {
6605
6639
  * This option configures a template controlling location of snapshots generated by
6606
6640
  * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
6607
6641
  * and
6608
- * [snapshotAssertions.toMatchSnapshot(name)](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
6642
+ * [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
6609
6643
  *
6610
6644
  * **Usage**
6611
6645
  *