Tests should not rely on external URLs, live websites, or internet connectivity to ensure reliability, consistency, and faster execution. External dependencies can cause tests to fail due to network issues, website changes, or unavailability, making CI/CD pipelines unstable.
Tests should not rely on external URLs, live websites, or internet connectivity to ensure reliability, consistency, and faster execution. External dependencies can cause tests to fail due to network issues, website changes, or unavailability, making CI/CD pipelines unstable.
Instead of using live URLs, use these alternatives:
chrome://version
, about:blank
, or similar built-in pagesExample of problematic code:
await page.goto('https://example.com') # External dependency
await page.goto('https://browserleaks.com/javascript') # External dependency
Example of improved code:
# Use pytest-httpserver (see test_controller.py)
await page.goto(f'http://localhost:{server.port}/test-page')
# Or use local browser pages
await page.goto('about:blank')
await page.goto('chrome://version')
This approach eliminates external dependencies, makes tests more reliable, reduces execution time, and ensures consistent results across different environments and network conditions.
Enter the URL of a public GitHub repository