Add a smoketest for packaging with parcel (#3371)

* Add a smoketest for packaging with parcel

* Prevent parcel from bundling shims for `process` or `buffer`
This commit is contained in:
Alexandru Dima 2022-10-18 19:49:55 +02:00 committed by GitHub
parent 2b3d8516c6
commit 8fc2ca540c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 4398 additions and 101 deletions

View file

@ -7,5 +7,5 @@
exports.__nothing = undefined;
/** @typedef {'chromium'|'firefox'|'webkit'} BrowserKind */
/** @typedef {'amd'|'webpack'|'esbuild'|'vite'} PackagerKind */
/** @typedef {'amd'|'webpack'|'esbuild'|'vite'|'parcel'} PackagerKind */
/** @typedef {{browser:BrowserKind; packager:PackagerKind; debugTests:boolean; port:number;}} TestInfo */

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div id="editor-container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
<script type="module" src="index.js"></script>
</body>
</html>

View file

@ -0,0 +1,35 @@
import * as monaco from '../../../release/esm/vs/editor/editor.main.js';
self.MonacoEnvironment = {
getWorker: function (moduleId, label) {
if (label === 'json') {
return new Worker(
new URL('../../../release/esm/vs/language/json/json.worker.js', import.meta.url),
{ type: 'module' }
);
}
if (label === 'css' || label === 'scss' || label === 'less') {
return new Worker(
new URL('../../../release/esm/vs/language/css/css.worker.js', import.meta.url),
{ type: 'module' }
);
}
if (label === 'html' || label === 'handlebars' || label === 'razor') {
return new Worker(
new URL('../../../release/esm/vs/language/html/html.worker.js', import.meta.url),
{ type: 'module' }
);
}
if (label === 'typescript' || label === 'javascript') {
return new Worker(
new URL('../../../release/esm/vs/language/typescript/ts.worker.js', import.meta.url),
{ type: 'module' }
);
}
return new Worker(new URL('../../../release/esm/vs/editor/editor.worker.js', import.meta.url), {
type: 'module'
});
}
};
window.monacoAPI = monaco;

View file

@ -0,0 +1,6 @@
{
"name": "parcel-smoketest",
"scripts": {
"package-for-smoketest-parcel": "parcel build ./index.html --cache-dir ./.cache --public-url /test/smoke/parcel/dist/ --no-optimize"
}
}

View file

@ -42,7 +42,7 @@ async function runTests() {
// uncomment to shortcircuit and run a specific combo
// await runTest('webpack', 'chromium'); return;
/** @type {PackagerKind[]} */
const testTypes = ['amd', 'webpack', 'esbuild', 'vite'];
const testTypes = ['amd', 'webpack', 'esbuild', 'vite', 'parcel'];
for (const type of testTypes) {
await runTest(type, 'chromium');

View file

@ -19,7 +19,8 @@ const URLS = {
amd: `http://127.0.0.1:${testInfo.port}/test/smoke/amd/index.html`,
webpack: `http://127.0.0.1:${testInfo.port}/test/smoke/webpack/index.html`,
esbuild: `http://127.0.0.1:${testInfo.port}/test/smoke/esbuild/index.html`,
vite: `http://127.0.0.1:${testInfo.port}/test/smoke/vite/dist/index.html`
vite: `http://127.0.0.1:${testInfo.port}/test/smoke/vite/dist/index.html`,
parcel: `http://127.0.0.1:${testInfo.port}/test/smoke/parcel/dist/index.html`
};
const URL = URLS[testInfo.packager];
@ -107,11 +108,11 @@ suite(`Smoke Test '${testInfo.packager}' on '${testInfo.browser}'`, () => {
await page.evaluate(`window.ed.focus();`);
}
test('`monacoAPI` is exposed as global', async () => {
test('`monacoAPI` is exposed as global', async function () {
assert.strictEqual(await page.evaluate(`typeof monacoAPI`), 'object');
});
test('should be able to create plaintext editor', async () => {
test('should be able to create plaintext editor', async function () {
await createEditor('hello world', 'plaintext');
// type a link in it
@ -122,14 +123,14 @@ suite(`Smoke Test '${testInfo.packager}' on '${testInfo.browser}'`, () => {
await page.waitForSelector('.detected-link');
});
test('css smoke test', async () => {
test('css smoke test', async function () {
await createEditor('.sel1 { background: red; }\\n.sel2 {}', 'css');
// check that a squiggle appears, which indicates that the language service is up and running
await page.waitForSelector('.squiggly-warning');
});
test('html smoke test', async () => {
test('html smoke test', async function () {
await createEditor('<title>hi</title>', 'html');
// we need to try this a couple of times because the web worker might not be ready yet
@ -151,7 +152,7 @@ suite(`Smoke Test '${testInfo.packager}' on '${testInfo.browser}'`, () => {
}
});
test('json smoke test', async () => {
test('json smoke test', async function () {
await createEditor('{}', 'json');
// we need to try this a couple of times because the web worker might not be ready yet
@ -168,7 +169,7 @@ suite(`Smoke Test '${testInfo.packager}' on '${testInfo.browser}'`, () => {
}
});
test('typescript smoke test', async () => {
test('typescript smoke test', async function () {
await createEditor('window.add', 'typescript');
// check that a squiggle appears, which indicates that the language service is up and running