|
5 | 5 | use Pest\Browser\Configuration; |
6 | 6 | use Pest\Browser\Playwright\Playwright; |
7 | 7 |
|
8 | | -beforeEach(function () { |
9 | | - // Reset Playwright state before each test |
| 8 | +beforeEach(function (): void { |
10 | 9 | Playwright::setLaunchArgs([]); |
11 | 10 | Playwright::setHeadedLaunchArgs([]); |
12 | 11 | Playwright::setHeadlessLaunchArgs([]); |
| 12 | + |
| 13 | + $reflection = new ReflectionClass(Playwright::class); |
| 14 | + $headlessProperty = $reflection->getProperty('headless'); |
| 15 | + $headlessProperty->setAccessible(true); |
| 16 | + $headlessProperty->setValue(null, true); |
13 | 17 | }); |
14 | 18 |
|
15 | | -test('can set custom launch arguments for all modes', function () { |
| 19 | +it('can set custom launch arguments for all modes', function (): void { |
16 | 20 | $args = ['--custom-flag', '--another-flag']; |
17 | 21 |
|
18 | 22 | Playwright::setLaunchArgs($args); |
|
21 | 25 | ->toBe($args); |
22 | 26 | }); |
23 | 27 |
|
24 | | -test('can set custom launch arguments for headed mode only', function () { |
| 28 | +it('can set custom launch arguments for headed mode only', function (): void { |
25 | 29 | $headedArgs = ['--headed-flag']; |
26 | 30 |
|
27 | 31 | Playwright::setHeadedLaunchArgs($headedArgs); |
28 | 32 |
|
29 | | - // In headless mode, should not include headed args |
30 | | - expect(Playwright::getEffectiveLaunchArgs()) |
31 | | - ->toBe([]); |
| 33 | + expect(Playwright::getEffectiveLaunchArgs())->toBe([]); |
32 | 34 |
|
33 | | - // Switch to headed mode |
34 | 35 | Playwright::headed(); |
35 | 36 |
|
36 | | - expect(Playwright::getEffectiveLaunchArgs()) |
37 | | - ->toBe($headedArgs); |
| 37 | + expect(Playwright::getEffectiveLaunchArgs())->toBe($headedArgs); |
38 | 38 | }); |
39 | 39 |
|
40 | | -test('can set custom launch arguments for headless mode only', function () { |
| 40 | +it('can set custom launch arguments for headless mode only', function (): void { |
41 | 41 | $headlessArgs = ['--headless-flag']; |
42 | 42 |
|
43 | 43 | Playwright::setHeadlessLaunchArgs($headlessArgs); |
44 | 44 |
|
45 | | - // In headless mode (default), should include headless args |
46 | | - expect(Playwright::getEffectiveLaunchArgs()) |
47 | | - ->toBe($headlessArgs); |
| 45 | + expect(Playwright::getEffectiveLaunchArgs())->toBe($headlessArgs); |
48 | 46 |
|
49 | | - // Switch to headed mode |
50 | 47 | Playwright::headed(); |
51 | 48 |
|
52 | | - expect(Playwright::getEffectiveLaunchArgs()) |
53 | | - ->toBe([]); |
| 49 | + expect(Playwright::getEffectiveLaunchArgs())->toBe([]); |
54 | 50 | }); |
55 | 51 |
|
56 | | -test('merges global and mode-specific arguments correctly', function () { |
| 52 | +it('merges global and mode-specific arguments correctly', function (): void { |
57 | 53 | $globalArgs = ['--global-flag']; |
58 | 54 | $headedArgs = ['--headed-flag']; |
59 | 55 | $headlessArgs = ['--headless-flag']; |
|
62 | 58 | Playwright::setHeadedLaunchArgs($headedArgs); |
63 | 59 | Playwright::setHeadlessLaunchArgs($headlessArgs); |
64 | 60 |
|
65 | | - // In headless mode (default) |
66 | | - expect(Playwright::getEffectiveLaunchArgs()) |
67 | | - ->toBe(['--global-flag', '--headless-flag']); |
| 61 | + expect(Playwright::getEffectiveLaunchArgs())->toBe(['--global-flag', '--headless-flag']); |
68 | 62 |
|
69 | | - // Switch to headed mode |
70 | 63 | Playwright::headed(); |
71 | 64 |
|
72 | | - expect(Playwright::getEffectiveLaunchArgs()) |
73 | | - ->toBe(['--global-flag', '--headed-flag']); |
| 65 | + expect(Playwright::getEffectiveLaunchArgs())->toBe(['--global-flag', '--headed-flag']); |
74 | 66 | }); |
75 | 67 |
|
76 | | -test('configuration withArgs method sets launch arguments', function () { |
| 68 | +it('configuration withArgs method sets launch arguments', function (): void { |
77 | 69 | $args = ['--config-flag']; |
78 | 70 |
|
79 | 71 | $config = new Configuration(); |
|
83 | 75 | expect(Playwright::getEffectiveLaunchArgs())->toBe($args); |
84 | 76 | }); |
85 | 77 |
|
86 | | -test('configuration withHeadedArgs method sets headed launch arguments', function () { |
| 78 | +it('configuration withHeadedArgs method sets headed launch arguments', function (): void { |
87 | 79 | $args = ['--headed-config-flag']; |
88 | 80 |
|
89 | 81 | $config = new Configuration(); |
90 | 82 | $result = $config->withHeadedArgs($args); |
91 | 83 |
|
92 | 84 | expect($result)->toBeInstanceOf(Configuration::class); |
93 | | - |
94 | | - // Should not be active in headless mode |
95 | 85 | expect(Playwright::getEffectiveLaunchArgs())->toBe([]); |
96 | 86 |
|
97 | | - // Should be active in headed mode |
98 | 87 | Playwright::headed(); |
99 | 88 | expect(Playwright::getEffectiveLaunchArgs())->toBe($args); |
100 | 89 | }); |
101 | 90 |
|
102 | | -test('configuration withHeadlessArgs method sets headless launch arguments', function () { |
| 91 | +it('configuration withHeadlessArgs method sets headless launch arguments', function (): void { |
103 | 92 | $args = ['--headless-config-flag']; |
104 | 93 |
|
105 | 94 | $config = new Configuration(); |
106 | 95 | $result = $config->withHeadlessArgs($args); |
107 | 96 |
|
108 | 97 | expect($result)->toBeInstanceOf(Configuration::class); |
109 | | - |
110 | | - // Should be active in headless mode (default) |
111 | 98 | expect(Playwright::getEffectiveLaunchArgs())->toBe($args); |
112 | 99 |
|
113 | | - // Should not be active in headed mode |
114 | 100 | Playwright::headed(); |
115 | 101 | expect(Playwright::getEffectiveLaunchArgs())->toBe([]); |
116 | 102 | }); |
117 | 103 |
|
118 | | -test('configuration methods can be chained', function () { |
| 104 | +it('configuration methods can be chained', function (): void { |
119 | 105 | $config = new Configuration(); |
120 | 106 |
|
121 | 107 | $result = $config |
|
0 commit comments