-
-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathConfiguration.php
More file actions
157 lines (126 loc) · 3.07 KB
/
Configuration.php
File metadata and controls
157 lines (126 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
declare(strict_types=1);
namespace Pest\Browser;
use Pest\Browser\Enums\BrowserType;
use Pest\Browser\Enums\ColorScheme;
use Pest\Browser\Playwright\Playwright;
/**
* @internal
*
* @codeCoverageIgnore
*/
final readonly class Configuration
{
/**
* Defaults the browser to Chrome.
*/
public function inChrome(): self
{
Playwright::setDefaultBrowserType(BrowserType::CHROME);
return $this;
}
/**
* Defaults the browser to Firefox.
*/
public function inFirefox(): self
{
Playwright::setDefaultBrowserType(BrowserType::FIREFOX);
return $this;
}
/**
* Defaults the browser to Safari.
*/
public function inSafari(): self
{
Playwright::setDefaultBrowserType(BrowserType::SAFARI);
return $this;
}
/**
* Sets the theme to light mode.
*/
public function inLightMode(): self
{
Playwright::setColorScheme(ColorScheme::LIGHT);
return $this;
}
/**
* Sets the theme to dark mode.
*/
public function inDarkMode(): self
{
Playwright::setColorScheme(ColorScheme::DARK);
return $this;
}
/**
* Sets the assertion's timeout in milliseconds.
*/
public function timeout(int $milliseconds): self
{
Playwright::setTimeout($milliseconds);
return $this;
}
/**
* Uses playwright in headed mode.
*/
public function headed(): self
{
Playwright::headed();
return $this;
}
/**
* Sets the browsers userAgent.
*/
public function userAgent(string $userAgent): self
{
Playwright::setUserAgent($userAgent);
return $this;
}
/**
* Sets the host for the server.
*/
public function withHost(?string $host): self
{
Playwright::setHost($host);
return $this;
}
/**
* Enables debug mode for assertions.
*/
public function debug(): self
{
Playwright::setShouldDebugAssertions();
return $this;
}
/**
* Enables diff mode for screenshot assertions.
*/
public function diff(): self
{
Playwright::setShouldDiffOnScreenshotAssertions();
return $this;
}
public function screenshotThreshold(float $threshold): self
{
Playwright::setScreenshotThreshold($threshold);
return $this;
}
/**
* Playwright will use MaxDiffPixels if non 0 and MaxDiffPixelRatio is not set
* else if both are set, it will choose the lower of the two
* else if none set it will have zero tolerance
*
* @see node_modules/playwright-core/lib/server/utils/comparators.js:88
*
* @return $this
*/
public function screenshotMaxDiffPixels(?int $maxDiffPixels): self
{
Playwright::setScreenshotMaxDiffPixels($maxDiffPixels);
return $this;
}
public function screenshotMaxDiffPixelRatio(float $maxDiffPixelRatio): self
{
Playwright::setScreenshotMaxDiffPixelRatio($maxDiffPixelRatio);
return $this;
}
}