Skip to content

Commit 5a6a493

Browse files
committed
Test style changes
1 parent 8c3a49e commit 5a6a493

File tree

1 file changed

+20
-34
lines changed

1 file changed

+20
-34
lines changed

tests/Unit/Playwright/LaunchArgsTest.php

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
use Pest\Browser\Configuration;
66
use Pest\Browser\Playwright\Playwright;
77

8-
beforeEach(function () {
9-
// Reset Playwright state before each test
8+
beforeEach(function (): void {
109
Playwright::setLaunchArgs([]);
1110
Playwright::setHeadedLaunchArgs([]);
1211
Playwright::setHeadlessLaunchArgs([]);
12+
13+
$reflection = new ReflectionClass(Playwright::class);
14+
$headlessProperty = $reflection->getProperty('headless');
15+
$headlessProperty->setAccessible(true);
16+
$headlessProperty->setValue(null, true);
1317
});
1418

15-
test('can set custom launch arguments for all modes', function () {
19+
it('can set custom launch arguments for all modes', function (): void {
1620
$args = ['--custom-flag', '--another-flag'];
1721

1822
Playwright::setLaunchArgs($args);
@@ -21,39 +25,31 @@
2125
->toBe($args);
2226
});
2327

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 {
2529
$headedArgs = ['--headed-flag'];
2630

2731
Playwright::setHeadedLaunchArgs($headedArgs);
2832

29-
// In headless mode, should not include headed args
30-
expect(Playwright::getEffectiveLaunchArgs())
31-
->toBe([]);
33+
expect(Playwright::getEffectiveLaunchArgs())->toBe([]);
3234

33-
// Switch to headed mode
3435
Playwright::headed();
3536

36-
expect(Playwright::getEffectiveLaunchArgs())
37-
->toBe($headedArgs);
37+
expect(Playwright::getEffectiveLaunchArgs())->toBe($headedArgs);
3838
});
3939

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 {
4141
$headlessArgs = ['--headless-flag'];
4242

4343
Playwright::setHeadlessLaunchArgs($headlessArgs);
4444

45-
// In headless mode (default), should include headless args
46-
expect(Playwright::getEffectiveLaunchArgs())
47-
->toBe($headlessArgs);
45+
expect(Playwright::getEffectiveLaunchArgs())->toBe($headlessArgs);
4846

49-
// Switch to headed mode
5047
Playwright::headed();
5148

52-
expect(Playwright::getEffectiveLaunchArgs())
53-
->toBe([]);
49+
expect(Playwright::getEffectiveLaunchArgs())->toBe([]);
5450
});
5551

56-
test('merges global and mode-specific arguments correctly', function () {
52+
it('merges global and mode-specific arguments correctly', function (): void {
5753
$globalArgs = ['--global-flag'];
5854
$headedArgs = ['--headed-flag'];
5955
$headlessArgs = ['--headless-flag'];
@@ -62,18 +58,14 @@
6258
Playwright::setHeadedLaunchArgs($headedArgs);
6359
Playwright::setHeadlessLaunchArgs($headlessArgs);
6460

65-
// In headless mode (default)
66-
expect(Playwright::getEffectiveLaunchArgs())
67-
->toBe(['--global-flag', '--headless-flag']);
61+
expect(Playwright::getEffectiveLaunchArgs())->toBe(['--global-flag', '--headless-flag']);
6862

69-
// Switch to headed mode
7063
Playwright::headed();
7164

72-
expect(Playwright::getEffectiveLaunchArgs())
73-
->toBe(['--global-flag', '--headed-flag']);
65+
expect(Playwright::getEffectiveLaunchArgs())->toBe(['--global-flag', '--headed-flag']);
7466
});
7567

76-
test('configuration withArgs method sets launch arguments', function () {
68+
it('configuration withArgs method sets launch arguments', function (): void {
7769
$args = ['--config-flag'];
7870

7971
$config = new Configuration();
@@ -83,39 +75,33 @@
8375
expect(Playwright::getEffectiveLaunchArgs())->toBe($args);
8476
});
8577

86-
test('configuration withHeadedArgs method sets headed launch arguments', function () {
78+
it('configuration withHeadedArgs method sets headed launch arguments', function (): void {
8779
$args = ['--headed-config-flag'];
8880

8981
$config = new Configuration();
9082
$result = $config->withHeadedArgs($args);
9183

9284
expect($result)->toBeInstanceOf(Configuration::class);
93-
94-
// Should not be active in headless mode
9585
expect(Playwright::getEffectiveLaunchArgs())->toBe([]);
9686

97-
// Should be active in headed mode
9887
Playwright::headed();
9988
expect(Playwright::getEffectiveLaunchArgs())->toBe($args);
10089
});
10190

102-
test('configuration withHeadlessArgs method sets headless launch arguments', function () {
91+
it('configuration withHeadlessArgs method sets headless launch arguments', function (): void {
10392
$args = ['--headless-config-flag'];
10493

10594
$config = new Configuration();
10695
$result = $config->withHeadlessArgs($args);
10796

10897
expect($result)->toBeInstanceOf(Configuration::class);
109-
110-
// Should be active in headless mode (default)
11198
expect(Playwright::getEffectiveLaunchArgs())->toBe($args);
11299

113-
// Should not be active in headed mode
114100
Playwright::headed();
115101
expect(Playwright::getEffectiveLaunchArgs())->toBe([]);
116102
});
117103

118-
test('configuration methods can be chained', function () {
104+
it('configuration methods can be chained', function (): void {
119105
$config = new Configuration();
120106

121107
$result = $config

0 commit comments

Comments
 (0)