mirror of
https://github.com/microsoft/monaco-editor.git
synced 2024-11-25 16:35:44 +08:00
Add webpack as part of the smoketest
This commit is contained in:
parent
423a55b305
commit
dfe35b15bb
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -41,5 +41,11 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: npm test
|
||||
|
||||
- name: Build webpack plugin
|
||||
run: npm run compile --prefix webpack-plugin
|
||||
|
||||
- name: Package using webpack plugin
|
||||
run: npm run smoketest --prefix webpack-plugin
|
||||
|
||||
- name: Run smoke test
|
||||
run: npm run smoketest
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
||||
**/node_modules/
|
||||
**/out/
|
||||
**/release/
|
||||
/webpack-plugin/test/dist/*.js
|
||||
/webpack-plugin/test/dist/*.ttf
|
||||
|
@ -1,4 +1,6 @@
|
||||
/out/
|
||||
**/node_modules/
|
||||
**/out/
|
||||
**/release/
|
||||
/monaco-editor-samples/browser-esm-parcel/.cache/
|
||||
/monaco-editor-samples/browser-esm-parcel/dist/
|
||||
/monaco-editor-samples/browser-esm-vite-react/dist/**/*.js
|
||||
@ -12,7 +14,4 @@
|
||||
/monaco-editor/typedoc/theme/
|
||||
/monaco-editor/typedoc/monaco.d.ts
|
||||
/monaco-editor/website/lib/
|
||||
/webpack-plugin/test/dist/*.js
|
||||
/webpack-plugin/out/
|
||||
/release/
|
||||
/src/typescript/lib/
|
||||
|
@ -12,7 +12,9 @@
|
||||
vs: '../../release/dev/vs'
|
||||
}
|
||||
});
|
||||
require(['vs/editor/editor.main'], () => {});
|
||||
require(['vs/editor/editor.main'], () => {
|
||||
window.monacoAPI = monaco;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -35,14 +35,21 @@ yaserver
|
||||
});
|
||||
|
||||
async function runTests() {
|
||||
await runTest('chromium');
|
||||
await runTest('firefox');
|
||||
// await runTest('webkit');
|
||||
for (const type of ['amd', 'webpack']) {
|
||||
await runTest(type, 'chromium');
|
||||
await runTest(type, 'firefox');
|
||||
// await runTest(type, 'webkit');
|
||||
}
|
||||
}
|
||||
|
||||
function runTest(browser) {
|
||||
/**
|
||||
* @param {string} type
|
||||
* @param {'chromium'|'firefox'|'webkit'} browser
|
||||
* @returns
|
||||
*/
|
||||
function runTest(type, browser) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const env = { BROWSER: browser, ...process.env };
|
||||
const env = { BROWSER: browser, TESTS_TYPE: type, ...process.env };
|
||||
if (DEBUG_TESTS) {
|
||||
env['DEBUG_TESTS'] = 'true';
|
||||
}
|
||||
|
@ -11,7 +11,12 @@ const { PORT } = require('./common');
|
||||
|
||||
const browserType = process.env.BROWSER || 'chromium';
|
||||
const DEBUG_TESTS = Boolean(process.env.DEBUG_TESTS || false);
|
||||
const URL = `http://127.0.0.1:${PORT}/test/smoke/amd.html`;
|
||||
const TESTS_TYPE = process.env.TESTS_TYPE || 'amd';
|
||||
|
||||
const URL =
|
||||
TESTS_TYPE === 'amd'
|
||||
? `http://127.0.0.1:${PORT}/test/smoke/amd.html`
|
||||
: `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`;
|
||||
|
||||
/** @type {playwright.Browser} */
|
||||
let browser;
|
||||
@ -59,8 +64,8 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe('Smoke Test', () => {
|
||||
it('`monaco` is exposed as global', async () => {
|
||||
assert.strictEqual(await page.evaluate(`typeof monaco`), 'object');
|
||||
it('`monacoAPI` is exposed as global', async () => {
|
||||
assert.strictEqual(await page.evaluate(`typeof monacoAPI`), 'object');
|
||||
});
|
||||
|
||||
/**
|
||||
@ -70,7 +75,7 @@ describe('Smoke Test', () => {
|
||||
*/
|
||||
async function createEditor(text, language) {
|
||||
return await page.evaluate(
|
||||
`window.ed = monaco.editor.create(document.getElementById('editor-container'), { value: '${text}', language: '${language}' })`
|
||||
`window.ed = monacoAPI.editor.create(document.getElementById('editor-container'), { value: '${text}', language: '${language}' })`
|
||||
);
|
||||
}
|
||||
|
10
test/smoke/webpack/webpack.html
Normal file
10
test/smoke/webpack/webpack.html
Normal 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="text/javascript" src="out/app.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,2 +1,3 @@
|
||||
/scripts/
|
||||
/src/
|
||||
/test/
|
||||
/smoketest/
|
||||
|
@ -5,11 +5,12 @@
|
||||
"main": "out/index.js",
|
||||
"typings": "./out/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "node ./node_modules/webpack/bin/webpack.js --config test/webpack.config.js --progress",
|
||||
"smoketest": "node ./node_modules/webpack/bin/webpack.js --config smoketest/webpack.config.js --progress",
|
||||
"test-cross-origin": "node ./node_modules/webpack/bin/webpack.js --config test/webpack-cross-origin.config.js --progress",
|
||||
"watch": "tsc -w -p tsconfig.json",
|
||||
"compile": "tsc -p tsconfig.json",
|
||||
"import-editor": "node ./scripts/import-editor.js",
|
||||
"prepublishOnly": "tsc -p tsconfig.json"
|
||||
"prepublishOnly": "npm run compile"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
4
webpack-plugin/smoketest/index.js
Normal file
4
webpack-plugin/smoketest/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||
|
||||
// expose the monaco API as a global for tests
|
||||
window.monacoAPI = monaco;
|
@ -1,17 +1,19 @@
|
||||
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(__dirname, 'dist'),
|
||||
path: path.resolve(REPO_ROOT, 'test/smoke/webpack/out'),
|
||||
filename: 'app.js'
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'monaco-editor': path.resolve(__dirname, '../../release')
|
||||
'monaco-editor': path.resolve(REPO_ROOT, 'release')
|
||||
}
|
||||
},
|
||||
module: {
|
||||
@ -28,7 +30,7 @@ module.exports = {
|
||||
},
|
||||
plugins: [
|
||||
new MonacoWebpackPlugin({
|
||||
monacoEditorPath: path.resolve(__dirname, '../../release')
|
||||
monacoEditorPath: path.resolve(REPO_ROOT, 'release')
|
||||
})
|
||||
]
|
||||
};
|
13
webpack-plugin/test/dist/index.html
vendored
13
webpack-plugin/test/dist/index.html
vendored
@ -1,13 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
||||
<script type="text/javascript" src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +0,0 @@
|
||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||
|
||||
monaco.editor.create(document.getElementById('container'), {
|
||||
value: 'console.log("Hello, world")',
|
||||
language: 'javascript'
|
||||
});
|
Loading…
Reference in New Issue
Block a user