Replace hard-coded URLs with environment variables #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements environment variable support for all URLs used in the Playwright test framework, following the Playwright documentation best practices for test parameterization.
Problem
Previously, all URLs were hard-coded throughout the codebase, making it difficult to:
For example, users wanting to test against
http://localhost:3000
had to manually edit multiple files.Solution
All hard-coded URLs have been replaced with environment variables using the pattern suggested in issue #56:
Environment Variables Introduced
BASE_URL
- Task management frontend applicationTASK_MGMT_API_URL
- Task management backend APIPLAYWRIGHT_DEV_URL
- Playwright documentation sitePETSTORE_API_URL
- Petstore API for examplesMOCKAROO_API_URL
- Mockaroo data generation APIA11Y_TEST_URL
- Accessibility testing URLAll variables include fallback values to the original hard-coded URLs, ensuring 100% backward compatibility.
Usage
Users can now create a
.env
file in the project root:And all tests will automatically use these URLs. If no
.env
file exists, tests will use the default production URLs.Files Modified
playwright.config.ts
,.env.example
tests/global.setup.ts
,tests/api.*.spec.ts
,tests/ui.example.spec.ts
,tests/a11y.lighthouse.spec.ts
tests/pageobjects/login.ts
,tests/pageobjects/playwright-dev-page.ts
README.md
,LEEME.md
(comprehensive documentation in English and Spanish)Benefits
✅ Easy environment switching without code changes
✅ Better local development workflow
✅ Follows Playwright best practices
✅ Fully backward compatible
✅ Well documented with examples
Resolves #56
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
task-mgmt-charlyautomatiza.onrender.com
/usr/local/bin/node /home/REDACTED/work/starter-playwright/starter-playwright/node_modules/playwright/lib/common/process.js
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.