mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 12:45:39 +01:00
Bring smoketest scripts together (#3370)
This commit is contained in:
parent
5d653b2569
commit
2b3d8516c6
15 changed files with 1546 additions and 112 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -48,7 +48,7 @@ jobs:
|
||||||
run: npm run compile --prefix webpack-plugin
|
run: npm run compile --prefix webpack-plugin
|
||||||
|
|
||||||
- name: Package using webpack plugin
|
- name: Package using webpack plugin
|
||||||
run: npm run package-for-smoketest --prefix webpack-plugin
|
run: npm run package-for-smoketest-webpack
|
||||||
|
|
||||||
- name: Package using esbuild
|
- name: Package using esbuild
|
||||||
run: npm run package-for-smoketest-esbuild
|
run: npm run package-for-smoketest-esbuild
|
||||||
|
|
|
||||||
1446
package-lock.json
generated
1446
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -17,6 +17,8 @@
|
||||||
"pretty-quick": "pretty-quick --staged",
|
"pretty-quick": "pretty-quick --staged",
|
||||||
"release": "ts-node ./build/build && ts-node ./build/release",
|
"release": "ts-node ./build/build && ts-node ./build/release",
|
||||||
"simpleserver": "ts-node ./build/simpleserver",
|
"simpleserver": "ts-node ./build/simpleserver",
|
||||||
|
"package-for-smoketest-webpack": "ts-node ./test/smoke/package-webpack",
|
||||||
|
"package-for-smoketest-webpack-cross-origin": "ts-node ./test/smoke/package-webpack --cross-origin",
|
||||||
"package-for-smoketest-esbuild": "ts-node ./test/smoke/package-esbuild",
|
"package-for-smoketest-esbuild": "ts-node ./test/smoke/package-esbuild",
|
||||||
"package-for-smoketest-vite": "ts-node ./test/smoke/package-vite",
|
"package-for-smoketest-vite": "ts-node ./test/smoke/package-vite",
|
||||||
"smoketest": "node ./test/smoke/runner.js",
|
"smoketest": "node ./test/smoke/runner.js",
|
||||||
|
|
@ -38,8 +40,10 @@
|
||||||
"@typescript/vfs": "^1.3.5",
|
"@typescript/vfs": "^1.3.5",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.6",
|
||||||
"clean-css": "^5.2.4",
|
"clean-css": "^5.2.4",
|
||||||
|
"css-loader": "^6.7.1",
|
||||||
"esbuild": "^0.14.49",
|
"esbuild": "^0.14.49",
|
||||||
"esbuild-plugin-alias": "^0.2.1",
|
"esbuild-plugin-alias": "^0.2.1",
|
||||||
|
"file-loader": "^6.2.0",
|
||||||
"glob": "^7.2.0",
|
"glob": "^7.2.0",
|
||||||
"husky": "^7.0.4",
|
"husky": "^7.0.4",
|
||||||
"jsdom": "^19.0.0",
|
"jsdom": "^19.0.0",
|
||||||
|
|
@ -50,6 +54,7 @@
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
"pretty-quick": "^3.1.3",
|
"pretty-quick": "^3.1.3",
|
||||||
"requirejs": "^2.3.6",
|
"requirejs": "^2.3.6",
|
||||||
|
"style-loader": "^3.3.1",
|
||||||
"terser": "^5.14.2",
|
"terser": "^5.14.2",
|
||||||
"ts-node": "^10.6.0",
|
"ts-node": "^10.6.0",
|
||||||
"typedoc": "^0.22.11",
|
"typedoc": "^0.22.11",
|
||||||
|
|
@ -61,6 +66,7 @@
|
||||||
"vscode-languageserver-textdocument": "^1.0.4",
|
"vscode-languageserver-textdocument": "^1.0.4",
|
||||||
"vscode-languageserver-types": "3.16.0",
|
"vscode-languageserver-types": "3.16.0",
|
||||||
"vscode-uri": "3.0.3",
|
"vscode-uri": "3.0.3",
|
||||||
|
"webpack": "^5.74.0",
|
||||||
"yaserver": "^0.4.0"
|
"yaserver": "^0.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="editor-container" style="position: absolute; width: 500px; height: 400px"></div>
|
<div id="editor-container" style="position: absolute; width: 500px; height: 400px"></div>
|
||||||
<script src="../../release/dev/vs/loader.js"></script>
|
<script src="../../../release/dev/vs/loader.js"></script>
|
||||||
<script>
|
<script>
|
||||||
require.config({
|
require.config({
|
||||||
paths: {
|
paths: {
|
||||||
vs: '../../release/dev/vs'
|
vs: '../../../release/dev/vs'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
require(['vs/editor/editor.main'], () => {
|
require(['vs/editor/editor.main'], () => {
|
||||||
|
|
@ -3,4 +3,9 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
exports.PORT = 8563;
|
/* keeping TS happy */
|
||||||
|
exports.__nothing = undefined;
|
||||||
|
|
||||||
|
/** @typedef {'chromium'|'firefox'|'webkit'} BrowserKind */
|
||||||
|
/** @typedef {'amd'|'webpack'|'esbuild'|'vite'} PackagerKind */
|
||||||
|
/** @typedef {{browser:BrowserKind; packager:PackagerKind; debugTests:boolean; port:number;}} TestInfo */
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import * as esbuild from 'esbuild';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { removeDir } from '../../build/fs';
|
import { removeDir } from '../../build/fs';
|
||||||
|
|
||||||
removeDir('test/smoke/esbuild/out', (entry) => /esbuild.html$/.test(entry));
|
removeDir('test/smoke/esbuild/out');
|
||||||
|
|
||||||
const workerEntryPoints = [
|
const workerEntryPoints = [
|
||||||
'vs/language/json/json.worker.js',
|
'vs/language/json/json.worker.js',
|
||||||
|
|
|
||||||
56
test/smoke/package-webpack.ts
Normal file
56
test/smoke/package-webpack.ts
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import webpack from 'webpack';
|
||||||
|
import MonacoWebpackPlugin from '../../webpack-plugin/out/index.js';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
const REPO_ROOT = path.join(__dirname, '../../');
|
||||||
|
const CROSS_ORIGIN_ASSETS = process.argv.includes('--cross-origin');
|
||||||
|
|
||||||
|
webpack(
|
||||||
|
{
|
||||||
|
mode: 'development',
|
||||||
|
entry: './index.js',
|
||||||
|
context: path.join(__dirname, 'webpack'),
|
||||||
|
output: {
|
||||||
|
path: path.resolve(REPO_ROOT, 'test/smoke/webpack/out'),
|
||||||
|
filename: 'app.js',
|
||||||
|
publicPath: CROSS_ORIGIN_ASSETS
|
||||||
|
? 'http://localhost:8088/monaco-editor/test/smoke/webpack/out/'
|
||||||
|
: undefined
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'monaco-editor': path.resolve(REPO_ROOT, 'release')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: ['style-loader', 'css-loader']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.ttf$/,
|
||||||
|
use: ['file-loader']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [<any>new MonacoWebpackPlugin({
|
||||||
|
monacoEditorPath: path.resolve(REPO_ROOT, 'release')
|
||||||
|
})]
|
||||||
|
},
|
||||||
|
(err: Error | undefined, stats: webpack.Stats | undefined) => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (stats && stats.hasErrors()) {
|
||||||
|
console.log(stats.compilation.errors);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
@ -9,10 +9,14 @@ const yaserver = require('yaserver');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { PORT } = require('./common');
|
|
||||||
const DEBUG_TESTS = process.argv.includes('--debug-tests');
|
|
||||||
|
|
||||||
|
/** @typedef {import('./common').BrowserKind} BrowserKind */
|
||||||
|
/** @typedef {import('./common').PackagerKind} PackagerKind */
|
||||||
|
/** @typedef {import('./common').TestInfo} TestInfo */
|
||||||
|
|
||||||
|
const DEBUG_TESTS = process.argv.includes('--debug-tests');
|
||||||
const REPO_ROOT = path.join(__dirname, '../../');
|
const REPO_ROOT = path.join(__dirname, '../../');
|
||||||
|
const PORT = 8563;
|
||||||
|
|
||||||
yaserver
|
yaserver
|
||||||
.createServer({
|
.createServer({
|
||||||
|
|
@ -37,7 +41,7 @@ yaserver
|
||||||
async function runTests() {
|
async function runTests() {
|
||||||
// uncomment to shortcircuit and run a specific combo
|
// uncomment to shortcircuit and run a specific combo
|
||||||
// await runTest('webpack', 'chromium'); return;
|
// await runTest('webpack', 'chromium'); return;
|
||||||
/** @type {('amd'|'webpack'|'esbuild'|'vite')[]} */
|
/** @type {PackagerKind[]} */
|
||||||
const testTypes = ['amd', 'webpack', 'esbuild', 'vite'];
|
const testTypes = ['amd', 'webpack', 'esbuild', 'vite'];
|
||||||
|
|
||||||
for (const type of testTypes) {
|
for (const type of testTypes) {
|
||||||
|
|
@ -48,16 +52,20 @@ async function runTests() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {'amd'|'webpack'|'esbuild'|'vite'} type
|
* @param {PackagerKind} packager
|
||||||
* @param {'chromium'|'firefox'|'webkit'} browser
|
* @param {BrowserKind} browser
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function runTest(type, browser) {
|
function runTest(packager, browser) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const env = { BROWSER: browser, TESTS_TYPE: type, ...process.env };
|
/** @type TestInfo */
|
||||||
if (DEBUG_TESTS) {
|
const testInfo = {
|
||||||
env['DEBUG_TESTS'] = 'true';
|
browser,
|
||||||
}
|
packager,
|
||||||
|
debugTests: DEBUG_TESTS,
|
||||||
|
port: PORT
|
||||||
|
};
|
||||||
|
const env = { MONACO_TEST_INFO: JSON.stringify(testInfo), ...process.env };
|
||||||
const proc = cp.spawn(
|
const proc = cp.spawn(
|
||||||
'node',
|
'node',
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -7,21 +7,23 @@
|
||||||
|
|
||||||
const playwright = require('playwright');
|
const playwright = require('playwright');
|
||||||
const { assert } = require('chai');
|
const { assert } = require('chai');
|
||||||
const { PORT } = require('./common');
|
|
||||||
|
|
||||||
const browserType = process.env.BROWSER || 'chromium';
|
/** @typedef {import('./common').BrowserKind} BrowserKind */
|
||||||
const DEBUG_TESTS = Boolean(process.env.DEBUG_TESTS || false);
|
/** @typedef {import('./common').PackagerKind} PackagerKind */
|
||||||
const TESTS_TYPE = process.env.TESTS_TYPE || 'amd';
|
/** @typedef {import('./common').TestInfo} TestInfo */
|
||||||
|
|
||||||
|
/** @type TestInfo */
|
||||||
|
const testInfo = JSON.parse(process.env.MONACO_TEST_INFO || '');
|
||||||
|
|
||||||
const URLS = {
|
const URLS = {
|
||||||
amd: `http://127.0.0.1:${PORT}/test/smoke/amd.html`,
|
amd: `http://127.0.0.1:${testInfo.port}/test/smoke/amd/index.html`,
|
||||||
webpack: `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`,
|
webpack: `http://127.0.0.1:${testInfo.port}/test/smoke/webpack/index.html`,
|
||||||
esbuild: `http://127.0.0.1:${PORT}/test/smoke/esbuild/esbuild.html`,
|
esbuild: `http://127.0.0.1:${testInfo.port}/test/smoke/esbuild/index.html`,
|
||||||
vite: `http://127.0.0.1:${PORT}/test/smoke/vite/dist/index.html`
|
vite: `http://127.0.0.1:${testInfo.port}/test/smoke/vite/dist/index.html`
|
||||||
};
|
};
|
||||||
const URL = URLS[TESTS_TYPE];
|
const URL = URLS[testInfo.packager];
|
||||||
|
|
||||||
suite(`Smoke Test '${TESTS_TYPE}' on '${browserType}'`, () => {
|
suite(`Smoke Test '${testInfo.packager}' on '${testInfo.browser}'`, () => {
|
||||||
/** @type {playwright.Browser} */
|
/** @type {playwright.Browser} */
|
||||||
let browser;
|
let browser;
|
||||||
|
|
||||||
|
|
@ -29,10 +31,10 @@ suite(`Smoke Test '${TESTS_TYPE}' on '${browserType}'`, () => {
|
||||||
let page;
|
let page;
|
||||||
|
|
||||||
suiteSetup(async () => {
|
suiteSetup(async () => {
|
||||||
browser = await playwright[browserType].launch({
|
browser = await playwright[testInfo.browser].launch({
|
||||||
headless: !DEBUG_TESTS,
|
headless: !testInfo.debugTests,
|
||||||
devtools: DEBUG_TESTS && browserType === 'chromium'
|
devtools: testInfo.debugTests && testInfo.browser === 'chromium'
|
||||||
// slowMo: DEBUG_TESTS ? 2000 : 0
|
// slowMo: testInfo.debugTests ? 2000 : 0
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@
|
||||||
"main": "out/index.js",
|
"main": "out/index.js",
|
||||||
"typings": "./out/index.d.ts",
|
"typings": "./out/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"package-for-smoketest": "node ./node_modules/webpack/bin/webpack.js --config smoketest/webpack.config.js --progress",
|
|
||||||
"smoketest-cross-origin": "node ./node_modules/webpack/bin/webpack.js --config smoketest/webpack-cross-origin.config.js --progress",
|
|
||||||
"watch": "tsc -w -p tsconfig.json",
|
"watch": "tsc -w -p tsconfig.json",
|
||||||
"compile": "tsc -p tsconfig.json",
|
"compile": "tsc -p tsconfig.json",
|
||||||
"import-editor": "node ./scripts/import-editor.js",
|
"import-editor": "node ./scripts/import-editor.js",
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
const MonacoWebpackPlugin = require('../out/index.js');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const ASSET_PATH = 'http://localhost:8088/monaco-editor/test/smoke/webpack/out/';
|
|
||||||
|
|
||||||
const REPO_ROOT = path.join(__dirname, '../../');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
mode: 'development',
|
|
||||||
entry: './index.js',
|
|
||||||
context: __dirname,
|
|
||||||
output: {
|
|
||||||
path: path.resolve(REPO_ROOT, 'test/smoke/webpack/out'),
|
|
||||||
filename: 'app.js',
|
|
||||||
publicPath: ASSET_PATH
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
'monaco-editor': path.resolve(REPO_ROOT, 'release')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
use: ['style-loader', 'css-loader']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.ttf$/,
|
|
||||||
use: ['file-loader']
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new MonacoWebpackPlugin({
|
|
||||||
monacoEditorPath: path.resolve(REPO_ROOT, 'release')
|
|
||||||
})
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
const MonacoWebpackPlugin = require('../out/index.js');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const REPO_ROOT = path.join(__dirname, '../../');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
mode: 'development',
|
|
||||||
entry: './index.js',
|
|
||||||
context: __dirname,
|
|
||||||
output: {
|
|
||||||
path: path.resolve(REPO_ROOT, 'test/smoke/webpack/out'),
|
|
||||||
filename: 'app.js'
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
'monaco-editor': path.resolve(REPO_ROOT, 'release')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
use: ['style-loader', 'css-loader']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.ttf$/,
|
|
||||||
use: ['file-loader']
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new MonacoWebpackPlugin({
|
|
||||||
monacoEditorPath: path.resolve(REPO_ROOT, 'release')
|
|
||||||
})
|
|
||||||
]
|
|
||||||
};
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue