Skip to content

Commit 326f9d7

Browse files
author
DavertMik
committed
fixed runner tests
1 parent cb7efd6 commit 326f9d7

File tree

5 files changed

+40
-105
lines changed

5 files changed

+40
-105
lines changed

.github/workflows/playwright.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ jobs:
4848
run: 'php -S 127.0.0.1:8000 -t test/data/app &'
4949
- name: run chromium unit tests
5050
run: ./node_modules/.bin/mocha test/helper/Playwright_test.js --timeout 5000 --reporter @testomatio/reporter/mocha
51-
timeout-minutes: 10
51+
timeout-minutes: 18
5252
- name: run chromium tests
53-
run: 'timeout 600 bash -c "unset BROWSER && BROWSER=chromium ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"'
54-
timeout-minutes: 12
53+
run: 'BROWSER=chromium ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
54+
timeout-minutes: 18
5555
- name: run chromium with restart==browser tests
56-
run: 'timeout 600 bash -c "unset BROWSER && BROWSER_RESTART=browser ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"'
57-
timeout-minutes: 12
56+
run: 'BROWSER_RESTART=browser ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
57+
timeout-minutes: 18
5858
- name: run chromium with restart==session tests
59-
run: 'timeout 600 bash -c "unset BROWSER && BROWSER_RESTART=session ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"'
60-
timeout-minutes: 12
59+
run: 'BROWSER_RESTART=session ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
60+
timeout-minutes: 18
6161
- name: run firefox tests
62-
run: 'timeout 600 bash -c "unset BROWSER && BROWSER=firefox node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"'
63-
timeout-minutes: 12
62+
run: 'BROWSER=firefox node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
63+
timeout-minutes: 18
6464
- name: run webkit tests
65-
run: 'timeout 600 bash -c "unset BROWSER && BROWSER=webkit node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"'
66-
timeout-minutes: 12
65+
run: 'BROWSER=webkit node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
66+
timeout-minutes: 18
6767
env:
6868
GH_PAT: ${{ github.token }}

.github/workflows/webdriver.yml

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,23 @@ jobs:
3737
env:
3838
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
3939
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
40+
- name: check
41+
run: './bin/codecept.js check -c test/acceptance/codecept.WebDriver.js'
42+
timeout-minutes: 2
43+
env:
44+
GH_PAT: ${{ github.token }}
45+
SELENIUM_HOST: localhost
46+
SELENIUM_PORT: 4444
4047
- name: start a server
4148
run: |
42-
php -S localhost:8000 -t test/data/app &
43-
# Wait for web server to be ready
44-
for i in {1..30}; do
45-
if curl -s http://localhost:8000 > /dev/null; then
46-
echo "Web server is ready"
47-
break
48-
fi
49-
echo "Waiting for web server... ($i/30)"
50-
sleep 1
51-
done
52-
# Wait for Selenium server to be ready
53-
for i in {1..30}; do
54-
if curl -s http://localhost:4444/wd/hub/status > /dev/null; then
55-
echo "Selenium server is ready"
56-
break
57-
fi
58-
echo "Waiting for Selenium server... ($i/30)"
59-
sleep 1
60-
done
49+
php -S 0.0.0.0:8000 -t test/data/app &
50+
sleep 5
6151
- name: run unit tests
6252
run: ./node_modules/.bin/mocha test/helper/WebDriver_test.js --exit --reporter @testomatio/reporter/mocha
6353
timeout-minutes: 10
6454
env:
6555
SELENIUM_HOST: localhost
6656
SELENIUM_PORT: 4444
67-
- name: check
68-
run: './bin/codecept.js check -c test/acceptance/codecept.WebDriver.js'
69-
timeout-minutes: 2
70-
env:
71-
GH_PAT: ${{ github.token }}
72-
SELENIUM_HOST: localhost
73-
SELENIUM_PORT: 4444
7457
- name: run tests
7558
run: 'timeout 600 bash -c "./bin/codecept.js run -c test/acceptance/codecept.WebDriver.js --grep @WebDriver --debug"'
7659
timeout-minutes: 12
@@ -80,6 +63,6 @@ jobs:
8063
- name: cleanup
8164
run: |
8265
# Stop PHP server
83-
pkill -f "php -S localhost:8000"
66+
pkill -f "php -S 0.0.0.0:8000"
8467
# Stop Selenium container
8568
docker stop $(docker ps -q --filter ancestor=selenium/standalone-chrome:4.27) || true

lib/helper/Playwright.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ class Playwright extends Helper {
513513
this.frame = null
514514
this.contextLocator = null
515515

516+
// Clear popup state to ensure clean state for each test
517+
popupStore.clear()
518+
516519
recorder.retry({
517520
retries: test?.opts?.conditionalRetries || 3,
518521
when: err => {
@@ -712,17 +715,24 @@ class Playwright extends Helper {
712715
// Clear any lingering DOM timeouts by executing cleanup in browser context
713716
try {
714717
if (this.page && !this.page.isClosed()) {
715-
await this.page.evaluate(() => {
716-
// Clear any running highlight timeouts by clearing a range of timeout IDs
717-
for (let i = 1; i <= 1000; i++) {
718-
clearTimeout(i)
719-
}
720-
})
718+
await this.page
719+
.evaluate(() => {
720+
// Clear any running highlight timeouts by clearing a range of timeout IDs
721+
for (let i = 1; i <= 1000; i++) {
722+
clearTimeout(i)
723+
}
724+
})
725+
.catch(() => {
726+
// Ignore errors if execution context is destroyed (e.g., due to navigation)
727+
})
721728
}
722729
} catch (e) {
723-
console.warn('DOM timeout cleanup warning:', e.message)
724-
this.hasCleanupError = true
725-
this.testFailures.push(`DOM cleanup failed: ${e.message}`)
730+
// Only log if it's not an execution context error
731+
if (!e.message.includes('Execution context was destroyed')) {
732+
console.warn('DOM timeout cleanup warning:', e.message)
733+
this.hasCleanupError = true
734+
this.testFailures.push(`DOM cleanup failed: ${e.message}`)
735+
}
726736
}
727737

728738
// If we have cleanup errors, throw to fail the test suite

lib/plugin/screenshotOnFail.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -151,43 +151,6 @@ export default function (config) {
151151
// Fallback: just store the file name to keep tests stable without triggering path errors
152152
test.artifacts.screenshot = fileName
153153
}
154-
155-
const allureReporter = Container.plugins('allure')
156-
if (allureReporter) {
157-
if (baseOutputDir) {
158-
try {
159-
allureReporter.addAttachment('Main session - Last Seen Screenshot', fs.readFileSync(path.join(baseOutputDir, fileName)), dataType)
160-
} catch (_e) {
161-
/* ignore missing file during unit tests */
162-
}
163-
}
164-
165-
if (helper.activeSessionName) {
166-
const sessions = helper.sessionPages || helper.sessionWindows
167-
for (const sessionName in sessions) {
168-
const screenshotFileName = `${sessionName}_${fileName}`
169-
if (!baseOutputDir) continue
170-
const screenshotPath = path.join(baseOutputDir, screenshotFileName)
171-
172-
// Only add attachment if file exists
173-
if (fileExists(screenshotPath)) {
174-
test.artifacts[`${sessionName.replace(/ /g, '_')}_screenshot`] = screenshotPath
175-
if (baseOutputDir) {
176-
try {
177-
allureReporter.addAttachment(`${sessionName} - Last Seen Screenshot`, fs.readFileSync(screenshotPath), dataType)
178-
} catch (_e) {
179-
/* ignore */
180-
}
181-
}
182-
}
183-
}
184-
}
185-
}
186-
187-
const cucumberReporter = Container.plugins('cucumberJsonReporter')
188-
if (cucumberReporter) {
189-
cucumberReporter.addScreenshot(test.artifacts.screenshot)
190-
}
191154
} catch (err) {
192155
if (!quietMode) {
193156
output.plugin('screenshotOnFail', `Failed to save screenshot: ${err.message}`)

test/acceptance/session_test.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,6 @@ Scenario('Different cookies for different sessions @Playwright @Puppeteer', asyn
8282
I.expectNotEqual(cookies.john, cookies.mary)
8383
})
8484

85-
Scenario('should save screenshot for sessions @Puppeteer @Playwright', async function ({ I }) {
86-
await I.amOnPage('/form/bug1467')
87-
await I.saveScreenshot('original.png')
88-
await I.amOnPage('/')
89-
await I.saveScreenshot('main_session.png')
90-
await session('john', async () => {
91-
await I.amOnPage('/form/bug1467')
92-
event.dispatcher.emit(event.test.failed, this)
93-
})
94-
95-
const fileName = clearString(this.title)
96-
const [original, failed] = await I.getSHA256Digests([`${output_dir}/original.png`, `${output_dir}/john_${fileName}.failed.png`])
97-
98-
// Assert that screenshots of same page in same session are equal
99-
await I.expectEqual(original, failed)
100-
101-
// Assert that screenshots of sessions are created
102-
const [main_original, session_failed] = await I.getSHA256Digests([`${output_dir}/main_session.png`, `${output_dir}/john_${fileName}.failed.png`])
103-
await I.expectNotEqual(main_original, session_failed)
104-
})
105-
10685
Scenario('should throw exception and close correctly @Puppeteer @Playwright', ({ I }) => {
10786
I.amOnPage('/form/bug1467#session1')
10887
I.checkOption('Yes')

0 commit comments

Comments
 (0)