From cdf4026fb669d49e6be18df6e05aa09d20a12e5c Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 10 Feb 2020 12:44:28 +0100 Subject: [PATCH] Add browser unit tests to product build (#90353) * wip - add browser unit tests to product build * run with more output * load loader via script tag --- .../darwin/product-build-darwin.yml | 6 ++++ .../linux/product-build-linux.yml | 6 ++++ .../win32/product-build-win32.yml | 7 ++++ test/unit/browser/index.js | 5 ++- test/unit/browser/renderer.html | 33 +++++++++++-------- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/build/azure-pipelines/darwin/product-build-darwin.yml b/build/azure-pipelines/darwin/product-build-darwin.yml index f6a268535ed..bb75d8570d7 100644 --- a/build/azure-pipelines/darwin/product-build-darwin.yml +++ b/build/azure-pipelines/darwin/product-build-darwin.yml @@ -99,6 +99,12 @@ steps: displayName: Run unit tests (Electron) condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) +- script: | + set -e + yarn test-browser --build --browser chromium --browser webkit + displayName: Run unit tests (Browser) + condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) + - script: | # Figure out the full absolute path of the product we just built # including the remote server and configure the integration tests diff --git a/build/azure-pipelines/linux/product-build-linux.yml b/build/azure-pipelines/linux/product-build-linux.yml index 6f14fee7d55..7cd8e730391 100644 --- a/build/azure-pipelines/linux/product-build-linux.yml +++ b/build/azure-pipelines/linux/product-build-linux.yml @@ -104,6 +104,12 @@ steps: displayName: Run unit tests (Electron) condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) +- script: | + set -e + DISPLAY=:10 yarn test-browser --build --browser chromium + displayName: Run unit tests (Browser) + condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) + - script: | # Figure out the full absolute path of the product we just built # including the remote server and configure the integration tests diff --git a/build/azure-pipelines/win32/product-build-win32.yml b/build/azure-pipelines/win32/product-build-win32.yml index db97a45dbb6..796259ab98b 100644 --- a/build/azure-pipelines/win32/product-build-win32.yml +++ b/build/azure-pipelines/win32/product-build-win32.yml @@ -112,6 +112,13 @@ steps: displayName: Run unit tests (Electron) condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) +- powershell: | + . build/azure-pipelines/win32/exec.ps1 + $ErrorActionPreference = "Stop" + exec { yarn test-browser --build --browser chromium } + displayName: Run unit tests (Browser) + condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) + - powershell: | # Figure out the full absolute path of the product we just built # including the remote server and configure the integration tests diff --git a/test/unit/browser/index.js b/test/unit/browser/index.js index a17acf6f87f..32ebdc1c87b 100644 --- a/test/unit/browser/index.js +++ b/test/unit/browser/index.js @@ -18,7 +18,7 @@ const playwright = require('playwright'); const defaultReporterName = process.platform === 'win32' ? 'list' : 'spec'; const optimist = require('optimist') // .describe('grep', 'only run tests matching ').alias('grep', 'g').alias('grep', 'f').string('grep') - // .describe('build', 'run with build output (out-build)').boolean('build') + .describe('build', 'run with build output (out-build)').boolean('build') .describe('run', 'only run tests matching ').string('run') .describe('glob', 'only run tests matching ').string('glob') .describe('debug', 'do not run browsers headless').boolean('debug') @@ -122,6 +122,9 @@ async function runTestsInBrowser(testModules, browserType) { const browser = await playwright[browserType].launch({ headless: !Boolean(argv.debug) }); const page = (await browser.defaultContext().pages())[0] const target = url.pathToFileURL(path.join(__dirname, 'renderer.html')); + if (argv.build) { + target.search = `?build=true`; + } await page.goto(target.href); const emitter = new events.EventEmitter(); diff --git a/test/unit/browser/renderer.html b/test/unit/browser/renderer.html index 2f46b408f41..59f984628a7 100644 --- a/test/unit/browser/renderer.html +++ b/test/unit/browser/renderer.html @@ -37,15 +37,21 @@ }); + + +