Skip to content

Commit 361fcf3

Browse files
committed
Run test in headless mode within CI
1 parent d6cb259 commit 361fcf3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Playwright Tests
22

3+
env:
4+
CI: true
5+
36
on:
47
push:
58
branches:
@@ -16,16 +19,16 @@ jobs:
1619
- name: Checkout repository
1720
uses: actions/checkout@v4
1821

19-
- name: Set up Python (latest)
22+
- name: Set up Python (latest stable version)
2023
uses: actions/setup-python@v4
2124
with:
22-
python-version: 'latest'
25+
python-version: '3.11'
2326

2427
- name: Install dependencies
2528
run: |
2629
python -m pip install --upgrade pip
2730
pip install -r requirements.txt
2831
playwright install --with-deps
2932
30-
- name: Run Playwright tests
31-
run: pytest tests
33+
- name: Run Playwright tests in headless mode
34+
run: pytest tests --headless

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ setup_and_run_tests:
2323
paths:
2424
- .cache/pip # Cache pip dependencies
2525
- /ms-playwright # Cache Playwright browsers
26+
variables:
27+
CI: "true"
2628

2729
pages:
2830
stage: pages

conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def request_context(
3737

3838
@pytest.fixture(scope="session")
3939
def browser(playwright):
40-
browser = playwright.chromium.launch(headless=False)
40+
headless = os.getenv("CI", "false").lower() == "true" # Headless only in CI
41+
browser = playwright.chromium.launch(headless=headless)
4142
yield browser
4243
browser.close()
4344

0 commit comments

Comments
 (0)