Skip to content

web: introduce `test-integration:debug` command

Warren Gifford requested to merge vb/test-integration-debug-cmd into main

Created by: valerybugakov

Context

Problem

According to our developer docs, the recommended way to debug integration tests locally is by:

  1. Building the web application with either yarn watch-web or yarn build-web.
  2. Running integration tests that would utility static assets created in the previous step.

This workflow is not optimized for fast iteration. Usually, there's no reason to rebuild the whole application to verify changes in the application logic.

Solution

Ideally, we want to rely on incremental builds that would allow an almost instant feedback cycle after changing the web application source code. This PR enables such a mechanism by introducing an environment variable DISABLE_APP_ASSETS_MOCKING, which disables mocking of index.html and web application build assets. Instead, these requests can go directly to the web-standalone server, powered by the webpack-dev-server and incremental builds.

Changes

  1. DISABLE_APP_ASSETS_MOCKING added to the Puppeteer driver configuration.
  2. DISABLE_APP_ASSETS_MOCKING is used to disable index.html and app assets mocking.
  3. yarn test-integration:debug is added to ease the use of the new environment variable.
  4. WINDOW_WIDTH and WINDOW_HEIGHT added to control browser window size for locally running integration tests.

Under the hood, the yarn test-integration:debug command uses several environment variables:

  1. KEEP_BROWSER=true to keep browser and current tab open on test completion
  2. DEVTOOLS=true to keep dev tools opened by default
  3. DISABLE_APP_ASSETS_MOCKING=true to enable faster iteration with webpack-dev-server.
  4. WINDOW_WIDTH=1920 WINDOW_HEIGHT=1080 for bigger window size to account for opened dev tools.

Test plan

Run yarn test-integration:debug PATH_TO_THE_TEST_FILE_TO_DEBUG locally along with sg start web-standalone to debug a specific integration test.

App preview:

Check out the client app preview documentation to learn more. Closes https://github.com/sourcegraph/sourcegraph/issues/37661

Merge request reports

Loading