Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 7, 2025

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:

  • Run tests against different environments (local, staging, production)
  • Test against local development servers
  • Configure different API endpoints without modifying source code

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:

async goto() {
  await this.page.goto(process.env.BASE_URL || 'https://charlyautomatiza.github.io/task-management-frontend');
}

Environment Variables Introduced

  • BASE_URL - Task management frontend application
  • TASK_MGMT_API_URL - Task management backend API
  • PLAYWRIGHT_DEV_URL - Playwright documentation site
  • PETSTORE_API_URL - Petstore API for examples
  • MOCKAROO_API_URL - Mockaroo data generation API
  • A11Y_TEST_URL - Accessibility testing URL

All 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:

BASE_URL=http://localhost:3000
TASK_MGMT_API_URL=http://localhost:4000

And all tests will automatically use these URLs. If no .env file exists, tests will use the default production URLs.

Files Modified

  • Configuration: playwright.config.ts, .env.example
  • Test Files: tests/global.setup.ts, tests/api.*.spec.ts, tests/ui.example.spec.ts, tests/a11y.lighthouse.spec.ts
  • Page Objects: tests/pageobjects/login.ts, tests/pageobjects/playwright-dev-page.ts
  • Documentation: 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
    • Triggering command: /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

This section details on the original issue you should resolve

<issue_title>Suggestion: Replace hard-coded URLS with ENV parameters</issue_title>
<issue_description>https://playwright.dev/docs/test-parameterize#passing-environment-variables

For example:

import "dotenv/config";

...

async goto() {
  await this.page.goto(proccess.env.TESTS_URL);
}

In my .env file I've configured the following:

TESTS_URL=http://localhost:3000
TESTS_BACKEND_API_URL=https://foo.bar
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

Fixes #40

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Update hard-coded URLs to use environment variables Replace hard-coded URLs with environment variables Oct 7, 2025
@Copilot Copilot AI requested a review from charlyautomatiza October 7, 2025 23:04
Copilot finished work on behalf of charlyautomatiza October 7, 2025 23:04
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.

Suggestion: Replace hard-coded URLS with ENV parameters

2 participants