diff --git a/.github/workflows/tests-backward-compat.yml b/.github/workflows/tests-backward-compat.yml index 4723ca684..97e7a5170 100644 --- a/.github/workflows/tests-backward-compat.yml +++ b/.github/workflows/tests-backward-compat.yml @@ -359,7 +359,7 @@ jobs: # Run Codeception Tests. - name: Run tests/${{ matrix.test-groups }} working-directory: ${{ env.PLUGIN_DIR }} - run: php vendor/bin/codecept run tests/${{ matrix.test-groups }} --fail-fast + run: php vendor/bin/codecept run tests/${{ matrix.test-groups }} --env headless --fail-fast # Artifacts are data generated by this workflow that we want to access, such as log files, screenshots, HTML output. # The if: failure() directive means that this will run when the workflow fails e.g. if a test fails, which is needed diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f46f553a1..f64d78e81 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -397,7 +397,7 @@ jobs: # Run Codeception Tests. - name: Run tests/${{ matrix.test-groups }} working-directory: ${{ env.PLUGIN_DIR }} - run: php vendor/bin/codecept run tests/${{ matrix.test-groups }} --fail-fast + run: php vendor/bin/codecept run tests/${{ matrix.test-groups }} --env headless --fail-fast # Artifacts are data generated by this workflow that we want to access, such as log files, screenshots, HTML output. # The if: failure() directive means that this will run when the workflow fails e.g. if a test fails, which is needed diff --git a/TESTING.md b/TESTING.md index 0c867bd14..131ecb5be 100644 --- a/TESTING.md +++ b/TESTING.md @@ -243,6 +243,17 @@ To run a specific End to End test in a specific folder (for example, `ActivateDe vendor/bin/codecept run EndtoEnd general/ActivateDeactivatePluginCest ``` +### Headed vs. headless Chrome + +End to End tests run Chrome in **headed** mode by default, so you can watch the browser as tests execute. This is useful when developing or debugging a test. + +To run tests in headless mode (no visible browser window), pass `--env headless`: +```bash +vendor/bin/codecept run EndToEnd --env headless +``` + +GitHub Actions runs tests with `--env headless`. Headed mode is for local development only. + For a full list of available wp-browser and Codeception functions that can be used for testing, see: - [wp-browser](https://wpbrowser.wptestkit.dev/modules) - [Codeception](https://codeception.com/docs/AcceptanceTests) diff --git a/tests/EndToEnd.suite.yml b/tests/EndToEnd.suite.yml index 8e565cf34..0b6d762fa 100644 --- a/tests/EndToEnd.suite.yml +++ b/tests/EndToEnd.suite.yml @@ -56,7 +56,6 @@ modules: capabilities: "goog:chromeOptions": args: - - "--headless" - "--disable-gpu" - "--disable-dev-shm-usage" - "--disable-software-rasterizer" @@ -84,4 +83,27 @@ modules: wpRootFolder: '%WORDPRESS_ROOT_DIR%' dbUrl: '%WORDPRESS_DB_URL%' domain: '%WORDPRESS_DOMAIN%' - \ No newline at end of file + +# Environments +# +# Run with `vendor/bin/codecept run EndToEnd --env headless` to run Chrome in +# headless mode (used by GitHub Actions). Without `--env headless`, Chrome runs +# in headed mode so a developer can watch tests execute locally. +env: + headless: + modules: + config: + lucatume\WPBrowser\Module\WPWebDriver: + capabilities: + "goog:chromeOptions": + args: + - "--headless" + - "--disable-gpu" + - "--disable-dev-shm-usage" + - "--disable-software-rasterizer" + - "--proxy-server='direct://'" + - "--proxy-bypass-list=*" + - "--no-sandbox" + - "--user-agent=%TEST_SITE_HTTP_USER_AGENT%" + prefs: + download.default_directory: '%WORDPRESS_ROOT_DIR%'