@vitest/browser-playwright 4.1.5 → 5.0.0-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +19 -3
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -497,6 +497,14 @@ function selectAll() {
497
497
  }
498
498
  }
499
499
 
500
+ const SCREENSHOT_STYLES = `
501
+ iframe[data-vitest="true"] {
502
+ position: absolute !important;
503
+ inset: 0 !important;
504
+ z-index: ${Number.MAX_SAFE_INTEGER} !important;
505
+ transform: none !important;
506
+ }
507
+ `;
500
508
  /**
501
509
  * Takes a screenshot using the provided browser context and returns a buffer and the expected screenshot path.
502
510
  *
@@ -517,13 +525,15 @@ async function takeScreenshot(context, name, options) {
517
525
  await mkdir(dirname(savePath), { recursive: true });
518
526
  }
519
527
  const mask = options.mask?.map((selector) => getDescribedLocator(context, selector));
528
+ const style = context.project.config.browser.ui ? options.style === undefined ? SCREENSHOT_STYLES : SCREENSHOT_STYLES + options.style : options.style;
520
529
  if (options.element) {
521
530
  const { element: selector, ...config } = options;
522
531
  const element = getDescribedLocator(context, selector);
523
532
  const buffer = await element.screenshot({
524
533
  ...config,
525
534
  mask,
526
- path: savePath
535
+ path: savePath,
536
+ style
527
537
  });
528
538
  return {
529
539
  buffer,
@@ -533,7 +543,8 @@ async function takeScreenshot(context, name, options) {
533
543
  const buffer = await getDescribedLocator(context, "body").screenshot({
534
544
  ...options,
535
545
  mask,
536
- path: savePath
546
+ path: savePath,
547
+ style
537
548
  });
538
549
  return {
539
550
  buffer,
@@ -757,6 +768,10 @@ const upload = async (context, selector, files, options) => {
757
768
  await getDescribedLocator(context, selector).setInputFiles(playwrightFiles, options);
758
769
  };
759
770
 
771
+ const viewport = async (context, options) => {
772
+ await context.page.setViewportSize(options);
773
+ };
774
+
760
775
  const wheel = async (context, selector, options) => {
761
776
  await hover(context, selector);
762
777
  const times = options.times ?? 1;
@@ -790,7 +805,8 @@ var commands = {
790
805
  __vitest_annotateTraces: annotateTraces,
791
806
  __vitest_markTrace: markTrace,
792
807
  __vitest_groupTraceStart: groupTraceStart,
793
- __vitest_groupTraceEnd: groupTraceEnd
808
+ __vitest_groupTraceEnd: groupTraceEnd,
809
+ __vitest_viewport: viewport
794
810
  };
795
811
 
796
812
  const pkgRoot = resolve(fileURLToPath(import.meta.url), "../..");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser-playwright",
3
3
  "type": "module",
4
- "version": "4.1.5",
4
+ "version": "5.0.0-beta.1",
5
5
  "description": "Browser running for Vitest using playwright",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -42,7 +42,7 @@
42
42
  ],
43
43
  "peerDependencies": {
44
44
  "playwright": "*",
45
- "vitest": "4.1.5"
45
+ "vitest": "5.0.0-beta.1"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "playwright": {
@@ -51,12 +51,12 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "tinyrainbow": "^3.1.0",
54
- "@vitest/mocker": "4.1.5",
55
- "@vitest/browser": "4.1.5"
54
+ "@vitest/mocker": "5.0.0-beta.1",
55
+ "@vitest/browser": "5.0.0-beta.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "playwright": "^1.59.0",
59
- "vitest": "4.1.5"
59
+ "vitest": "5.0.0-beta.1"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "premove dist && pnpm rollup -c",