Add browser unit tests to product build (#90353)
* wip - add browser unit tests to product build * run with more output * load loader via script tagpull/90374/head
parent
7b8c5cdf86
commit
cdf4026fb6
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <pattern>').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 <relative_file_path>').string('run')
|
||||
.describe('glob', 'only run tests matching <glob_pattern>').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();
|
||||
|
|
|
@ -37,15 +37,21 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<!-- Depending on --build or not, load loader from known locations -->
|
||||
<script src="../../../out/vs/loader.js"></script>
|
||||
<script src="../../../out-build/vs/loader.js"></script>
|
||||
|
||||
<script>
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const isBuild = urlParams.get('build');
|
||||
|
||||
// configure loader
|
||||
const baseUrl = window.location.href;
|
||||
require.config({
|
||||
catchError: true,
|
||||
baseUrl: new URL('../../../src', baseUrl).href,
|
||||
paths: {
|
||||
'vs': new URL('../../../out/vs', baseUrl).href,
|
||||
'vs': new URL(`../../../${!!isBuild ? 'out-build' : 'out'}/vs`, baseUrl).href,
|
||||
assert: new URL('../assert.js', baseUrl).href,
|
||||
sinon: new URL('../../../node_modules/sinon/pkg/sinon-1.17.7.js', baseUrl).href
|
||||
}
|
||||
|
@ -104,19 +110,19 @@
|
|||
|
||||
window.loadAndRun = async function loadAndRun(modules, manual = false) {
|
||||
// load
|
||||
// await Promise.all(modules.map(module => new Promise((resolve, reject) =>{
|
||||
// require([module], resolve, err => {
|
||||
// console.log("BAD " + module + JSON.stringify(err, undefined, '\t'));
|
||||
// // console.log(module);
|
||||
// resolve({});
|
||||
// });
|
||||
// })));
|
||||
await new Promise((resolve, reject) => {
|
||||
require(modules, resolve, err => {
|
||||
console.log(err);
|
||||
reject(err);
|
||||
await Promise.all(modules.map(module => new Promise((resolve, reject) => {
|
||||
require([module], resolve, err => {
|
||||
console.log("BAD " + module + JSON.stringify(err, undefined, '\t'));
|
||||
// console.log(module);
|
||||
resolve({});
|
||||
});
|
||||
});
|
||||
})));
|
||||
// await new Promise((resolve, reject) => {
|
||||
// require(modules, resolve, err => {
|
||||
// console.log(err);
|
||||
// reject(err);
|
||||
// });
|
||||
// });
|
||||
|
||||
// run
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -127,7 +133,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
const modules = new URL(window.location.href).searchParams.getAll('m');
|
||||
if (Array.isArray(modules) && modules.length > 0) {
|
||||
console.log('MANUALLY running tests', modules);
|
||||
|
|
Loading…
Reference in New Issue