web: introduce `test-integration:debug` command
Created by: valerybugakov
Context
Problem
According to our developer docs, the recommended way to debug integration tests locally is by:
- Building the web application with either
yarn watch-web
oryarn build-web
. - 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
-
DISABLE_APP_ASSETS_MOCKING
added to the Puppeteer driver configuration. -
DISABLE_APP_ASSETS_MOCKING
is used to disableindex.html
and app assets mocking. -
yarn test-integration:debug
is added to ease the use of the new environment variable. -
WINDOW_WIDTH
andWINDOW_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:
-
KEEP_BROWSER=true
to keep browser and current tab open on test completion -
DEVTOOLS=true
to keep dev tools opened by default -
DISABLE_APP_ASSETS_MOCKING=true
to enable faster iteration withwebpack-dev-server
. -
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