Skip to content

feat(testing): support browser executable path detection via environm… #6308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

christian-bromann
Copy link
Member

What is the current behavior?

GitHub Issue Number: #6213

The PUPPETEER_EXECUTABLE_PATH environment variable is not being respected when running Stencil tests with Puppeteer. Users who set this environment variable to specify a custom browser executable (e.g., in Docker environments where Chromium is installed separately) encounter errors because Stencil is not using the specified path.

The current implementation only checks config.testing.browserExecutablePath but ignores common environment variables that users expect to work with Puppeteer.

What is the new behavior?

This PR implements a robust fallback chain for browser executable path detection:

  1. Environment Variables Support: Automatically detects browser executables from:

    • PUPPETEER_EXECUTABLE_PATH - Standard Puppeteer environment variable
    • CHROME_PATH - Common Chrome/Chromium path variable
    • Falls back to puppeteer.puppeteerExecutablePath() if neither is set
  2. Improved Documentation: Added comprehensive JSDoc documentation for the browserExecutablePath property explaining the new default behavior and fallback chain.

  3. Simplified Logic: Removed conditional logic in favor of a unified fallback resolution approach that always provides a value.

This change ensures that users can specify browser executables through environment variables without requiring explicit configuration, which is especially important for CI/CD environments and Docker deployments.

Documentation

The JSDoc documentation for TestingConfig.browserExecutablePath has been updated to reflect the new default behavior and fallback chain.

Does this introduce a breaking change?

  • Yes
  • No

This change is backward compatible. The browserExecutablePath configuration option still works as before, but now users have additional options through environment variables when this config is not explicitly set.

Testing

  • Verified that existing browserExecutablePath configuration still works
  • Tested environment variable fallback chain:
    • PUPPETEER_EXECUTABLE_PATH takes precedence
    • CHROME_PATH is used when PUPPETEER_EXECUTABLE_PATH is not set
    • Default Puppeteer executable path is used when neither environment variable is set
  • Confirmed the fix resolves the issue described in bug: PUPPETEER_EXECUTABLE_PATH broken since 4.24.0 #6213

Other information

This addresses the regression introduced in recent versions where PUPPETEER_EXECUTABLE_PATH stopped working. The fix ensures that Docker users and CI/CD environments can continue to use this standard environment variable to specify custom browser executables without additional configuration.

The implementation follows Puppeteer's own environment variable conventions, making it more intuitive for users already familiar with Puppeteer's behavior.

…ent variables

Add fallback chain for browser executable path using PUPPETEER_EXECUTABLE_PATH
and CHROME_PATH environment variables, improving automatic browser detection
for Puppeteer-based testing.
@ReneWerner87
Copy link

testing of the fix
#6213 (comment)

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.

2 participants