Skip to content

Commit 61d43fa

Browse files
committed
fix(playwright): Fix an error with mask option
1 parent 38ddbab commit 61d43fa

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.changeset/three-poets-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@quickpickle/playwright": patch
3+
---
4+
5+
Fix an error that arises when a mask is set and two screenshots are taken within one test.

packages/playwright/src/PlaywrightWorld.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class PlaywrightWorld extends VisualWorld implements VisualWorldInterface
307307

308308
get screenshotOptions() {
309309
let opts = defaultsDeep(this.worldConfig.screenshotOptions || {}, this.worldConfig.screenshotOpts || {})
310-
if (opts.mask) opts.mask = opts.mask.map((m:string) => this.page.locator(m))
310+
if (opts.mask) opts.mask = opts.mask.map((m:string|Locator) => typeof m === 'string' ? this.page.locator(m) : m)
311311
return opts
312312
}
313313

packages/playwright/tests/playwright.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ Feature: Basic tests of Playwright browser and steps
9595
```
9696
Then the screenshot should match
9797

98+
Scenario: Two screenshots with a mask
99+
Given I load the file "tests/examples/example.html"
100+
And the following world config:
101+
```yaml
102+
screenshotOptions:
103+
mask:
104+
- form
105+
```
106+
When I take a screenshot named "mask"
107+
And I take a screenshot named "mask"
108+
Then the screenshot "mask.png" should exist--delete it
109+
110+
98111
Rule: Screenshots should be placed in the proper directory
99112

100113
Scenario: Taking a screenshot

0 commit comments

Comments
 (0)