Smoketest improvements: (#3369)

- Add a smoketest for packaging with vite
- Re-enable the smoketest for packaging with esbuild
- Re-enable the smoketest on webkit
This commit is contained in:
Alexandru Dima 2022-10-18 10:26:38 +02:00 committed by GitHub
parent a3d4b960c5
commit 5d653b2569
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 934 additions and 12 deletions

View file

@ -1,3 +1,8 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as monaco from '../../../release/esm/vs/editor/editor.main.js';
self.MonacoEnvironment = {

View file

@ -0,0 +1,19 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vite from 'vite';
import * as path from 'path';
async function main() {
await vite.build({
root: path.resolve(__dirname, './vite/'),
base: '/test/smoke/vite/dist/',
build: {
minify: false
}
});
}
main();

View file

@ -37,16 +37,18 @@ yaserver
async function runTests() {
// uncomment to shortcircuit and run a specific combo
// await runTest('webpack', 'chromium'); return;
/** @type {('amd'|'webpack'|'esbuild'|'vite')[]} */
const testTypes = ['amd', 'webpack', 'esbuild', 'vite'];
for (const type of ['amd', 'webpack' /*, 'esbuild'*/]) {
for (const type of testTypes) {
await runTest(type, 'chromium');
await runTest(type, 'firefox');
// await runTest(type, 'webkit');
await runTest(type, 'webkit');
}
}
/**
* @param {string} type
* @param {'amd'|'webpack'|'esbuild'|'vite'} type
* @param {'chromium'|'firefox'|'webkit'} browser
* @returns
*/

View file

@ -13,12 +13,13 @@ const browserType = process.env.BROWSER || 'chromium';
const DEBUG_TESTS = Boolean(process.env.DEBUG_TESTS || false);
const TESTS_TYPE = process.env.TESTS_TYPE || 'amd';
const URL =
TESTS_TYPE === 'amd'
? `http://127.0.0.1:${PORT}/test/smoke/amd.html`
: TESTS_TYPE === 'webpack'
? `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`
: `http://127.0.0.1:${PORT}/test/smoke/esbuild/esbuild.html`;
const URLS = {
amd: `http://127.0.0.1:${PORT}/test/smoke/amd.html`,
webpack: `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`,
esbuild: `http://127.0.0.1:${PORT}/test/smoke/esbuild/esbuild.html`,
vite: `http://127.0.0.1:${PORT}/test/smoke/vite/dist/index.html`
};
const URL = URLS[TESTS_TYPE];
suite(`Smoke Test '${TESTS_TYPE}' on '${browserType}'`, () => {
/** @type {playwright.Browser} */
@ -184,7 +185,7 @@ suite(`Smoke Test '${TESTS_TYPE}' on '${browserType}'`, () => {
// find the TypeScript worker
const tsWorker = page.workers().find((worker) => {
const url = worker.url();
return /ts\.worker\.js$/.test(url) || /workerMain.js#typescript$/.test(url);
return /ts\.worker(\.[a-f0-9]+)?\.js$/.test(url) || /workerMain.js#typescript$/.test(url);
});
if (!tsWorker) {
assert.fail('Could not find TypeScript worker');

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div id="editor-container" style="position: absolute; width: 500px; height: 400px"></div>
<script type="module" src="index.js"></script>
</body>
</html>

31
test/smoke/vite/index.js Normal file
View file

@ -0,0 +1,31 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as monaco from '../../../release/esm/vs/editor/editor.main';
import editorWorker from '../../../release/esm/vs/editor/editor.worker?worker';
import jsonWorker from '../../../release/esm/vs/language/json/json.worker?worker';
import cssWorker from '../../../release/esm/vs/language/css/css.worker?worker';
import htmlWorker from '../../../release/esm/vs/language/html/html.worker?worker';
import tsWorker from '../../../release/esm/vs/language/typescript/ts.worker?worker';
self.MonacoEnvironment = {
getWorker(moduleId, label) {
if (label === 'json') {
return new jsonWorker();
}
if (label === 'css' || label === 'scss' || label === 'less') {
return new cssWorker();
}
if (label === 'html' || label === 'handlebars' || label === 'razor') {
return new htmlWorker();
}
if (label === 'typescript' || label === 'javascript') {
return new tsWorker();
}
return new editorWorker();
}
};
window.monacoAPI = monaco;