Skip to content

Commit ba58ee6

Browse files
Copilotkobenguyent
andcommitted
Changes before error encountered
Co-authored-by: kobenguyent <[email protected]>
1 parent e564a2a commit ba58ee6

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

.github/workflows/testcafe.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ env:
1616

1717
jobs:
1818
build:
19-
20-
runs-on: ubuntu-24.04
21-
2219
strategy:
2320
matrix:
24-
node-version: [22.x]
21+
os: [ubuntu-22.04, macos-13, windows-2022]
22+
php-version: ['8.1', '8.2']
23+
node-version: [20.x]
24+
fail-fast: false
25+
26+
runs-on: ${{ matrix.os }}
2527

2628
steps:
2729
- uses: actions/checkout@v5
@@ -31,14 +33,21 @@ jobs:
3133
node-version: ${{ matrix.node-version }}
3234
- uses: shivammathur/setup-php@v2
3335
with:
34-
php-version: 7.4
36+
php-version: ${{ matrix.php-version }}
3537
- name: npm install
3638
run: |
3739
npm i --force
3840
env:
3941
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
4042
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
4143
- name: start a server
42-
run: "php -S 127.0.0.1:8000 -t test/data/app &"
44+
run: |
45+
if [ "$RUNNER_OS" == "Windows" ]; then
46+
start /B php -S 127.0.0.1:8000 -t test/data/app
47+
else
48+
php -S 127.0.0.1:8000 -t test/data/app &
49+
fi
50+
sleep 3
51+
shell: bash
4352
- name: run unit tests
4453
run: npm run test:unit:webbapi:testCafe

lib/utils.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,12 @@ module.exports.test = {
192192
submittedData(dataFile) {
193193
return function (key) {
194194
if (!fs.existsSync(dataFile)) {
195-
// Increase wait time for CI environments where form submission may be slower
196-
const waitTime = process.env.CI ? 45 * 1000 : 1 * 1000 // 45 seconds in CI, 1 second otherwise
197-
const pollInterval = 500 // Check every 500ms to reduce load
195+
// Reduce wait time while maintaining reliability across different environments
196+
const waitTime = process.env.CI ? 30 * 1000 : 1 * 1000 // 30 seconds in CI, 1 second otherwise
197+
const pollInterval = 250 // Check every 250ms for faster detection
198198
const startTime = new Date().getTime()
199199

200-
// Poll for file existence with exponential backoff-style intervals
201-
let currentInterval = pollInterval
200+
// Poll for file existence with optimized intervals
202201
while (new Date().getTime() - startTime < waitTime) {
203202
if (fs.existsSync(dataFile)) {
204203
break
@@ -208,24 +207,21 @@ module.exports.test = {
208207
try {
209208
if (os.platform() === 'win32') {
210209
// Use timeout command which is more reliable than ping
211-
spawnSync('timeout', ['/t', Math.ceil(currentInterval / 1000).toString()], { stdio: 'ignore' })
210+
spawnSync('timeout', ['/t', '1'], { stdio: 'ignore' })
212211
} else {
213212
// Use sleep with fractional seconds for better precision
214-
spawnSync('sleep', [(currentInterval / 1000).toString()], { stdio: 'ignore' })
213+
spawnSync('sleep', [(pollInterval / 1000).toString()], { stdio: 'ignore' })
215214
}
216215
} catch (err) {
217216
// Fallback to setTimeout-based delay if system commands fail
218-
const end = new Date().getTime() + currentInterval
217+
const end = new Date().getTime() + pollInterval
219218
while (new Date().getTime() < end) {
220219
// Small yield to prevent complete CPU lock
221220
if (new Date().getTime() % 10 === 0) {
222221
process.nextTick(() => {})
223222
}
224223
}
225224
}
226-
227-
// Gradually increase interval to reduce polling frequency over time
228-
currentInterval = Math.min(currentInterval * 1.2, 2000)
229225
}
230226
}
231227
if (!fs.existsSync(dataFile)) {

test/helper/TestCafe_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let I
1010
const siteUrl = TestHelper.siteUrl()
1111

1212
describe('TestCafe', function () {
13-
this.timeout(120000) // Increased timeout for CI environment
13+
this.timeout(60000) // Reduced timeout from 120s to 60s for faster feedback
1414
this.retries(1)
1515

1616
before(() => {

0 commit comments

Comments
 (0)