Skip to content

Comments

Apply TIMEOUT_MULTIPLIER globally across codebase#5

Open
wittjeff wants to merge 1 commit intojrpool:mainfrom
wittjeff:apply-timeout-multiplier-globally
Open

Apply TIMEOUT_MULTIPLIER globally across codebase#5
wittjeff wants to merge 1 commit intojrpool:mainfrom
wittjeff:apply-timeout-multiplier-globally

Conversation

@wittjeff
Copy link

@wittjeff wittjeff commented Feb 5, 2026

Summary

This PR centralizes the TIMEOUT_MULTIPLIER environment variable and applies it consistently to all appropriate timeouts throughout Testaro.

Problem

Currently, TIMEOUT_MULTIPLIER is only honored in two places:

  • run.js - for tool-level time limits
  • tests/testaro.js - for individual rule timeouts

Many other hardcoded timeouts (navigation, interactions, page loads) ignore this setting, making it impossible to adjust timing for slow networks or JavaScript-heavy sites.

Solution

  1. Created procs/config.js - A shared module that exports:

    • timeoutMultiplier - the multiplier value from env var (default: 1)
    • applyMultiplier(timeout) - helper function to apply the multiplier
  2. Updated files to use the shared config:

File Timeouts Updated Purpose
run.js 15 timeouts Navigation, page loads, interactions
tests/alfa.js 1 timeout networkidle wait (base increased 2s→6s)
tests/aslint.js 1 timeout Script evaluation
tests/testaro.js (imports from config) Rule timeouts
procs/screenShot.js 1 timeout Screenshot capture
testaro/tabNav.js 2 timeouts Tab click/keypress
testaro/hover.js 1 timeout Hover action
  1. Timeouts intentionally NOT modified (fail-fast operations):
    • tests/alfa.js boundingBox/innerText (50ms)
    • procs/identify.js element ID (100ms)

Usage

# For slow networks/sites, increase the multiplier:
TIMEOUT_MULTIPLIER=2 npx testaro ...

# For very slow sites (like Wix):
TIMEOUT_MULTIPLIER=3 npx testaro ...

Default behavior is unchanged (TIMEOUT_MULTIPLIER=1).

Testing

  • Verified all imports resolve correctly
  • The applyMultiplier() function uses Math.round() to ensure integer timeout values
  • Backward compatible - no changes to default behavior

Related

This PR supersedes #4 (alfa timeout increase) by including that fix plus applying the multiplier globally.

This change centralizes the TIMEOUT_MULTIPLIER environment variable
and applies it consistently to all appropriate timeouts throughout
Testaro.

Changes:
- Add procs/config.js as a shared module exporting timeoutMultiplier
  and an applyMultiplier() helper function
- Update run.js to import from shared config and apply multiplier to
  15 navigation/interaction timeouts (5000-15000ms range)
- Update tests/alfa.js to use multiplier on networkidle wait (also
  increases base timeout from 2000ms to 6000ms for slow-loading sites)
- Update tests/aslint.js to use multiplier on script evaluation timeout
- Update tests/testaro.js to import from shared config instead of
  defining timeoutMultiplier locally
- Update procs/screenShot.js to use multiplier on screenshot timeout
- Update testaro/tabNav.js to use multiplier on click/keypress timeouts
- Update testaro/hover.js to use multiplier on hover timeout

Timeouts intentionally NOT modified (fail-fast operations):
- tests/alfa.js boundingBox/innerText (50ms) - quick info gathering
- procs/identify.js element ID (100ms) - quick element identification

Usage: Set TIMEOUT_MULTIPLIER=2 (or higher) for slow networks/sites.
Default value is 1 (no change to existing behavior).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@juanscasado
Copy link

Hi @jrpool, please send me the invitation again to join. I could not accept, please sendme the request to juans.casado@hotmail.com, and please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants