mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 03:30:10 +01:00
Adjust smoke test which also uses mocha
This commit is contained in:
parent
41ded74b37
commit
7e766abe78
4 changed files with 45 additions and 46 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"delay": true,
|
"delay": true,
|
||||||
"ui": "tdd",
|
"ui": "tdd"
|
||||||
"spec": "test/unit/all.js"
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
"simpleserver": "node ./build/simpleserver",
|
"simpleserver": "node ./build/simpleserver",
|
||||||
"smoketest-debug": "node ./test/smoke/runner.js --debug-tests",
|
"smoketest-debug": "node ./test/smoke/runner.js --debug-tests",
|
||||||
"smoketest": "node ./test/smoke/runner.js",
|
"smoketest": "node ./test/smoke/runner.js",
|
||||||
"test": "mocha",
|
"test": "mocha test/unit/all.js",
|
||||||
"typedoc": "cd website/typedoc && \"../../node_modules/.bin/typedoc\" --options ./typedoc.json",
|
"typedoc": "cd website/typedoc && \"../../node_modules/.bin/typedoc\" --options ./typedoc.json",
|
||||||
"watch": "tsc -w -p ./src"
|
"watch": "tsc -w -p ./src"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ function runTest(type, browser) {
|
||||||
[
|
[
|
||||||
path.join(REPO_ROOT, 'node_modules/mocha/bin/mocha'),
|
path.join(REPO_ROOT, 'node_modules/mocha/bin/mocha'),
|
||||||
'test/smoke/*.test.js',
|
'test/smoke/*.test.js',
|
||||||
|
'--no-delay',
|
||||||
'--headless',
|
'--headless',
|
||||||
'--timeout',
|
'--timeout',
|
||||||
'20000'
|
'20000'
|
||||||
|
|
|
||||||
|
|
@ -18,52 +18,51 @@ const URL =
|
||||||
? `http://127.0.0.1:${PORT}/test/smoke/amd.html`
|
? `http://127.0.0.1:${PORT}/test/smoke/amd.html`
|
||||||
: `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`;
|
: `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`;
|
||||||
|
|
||||||
/** @type {playwright.Browser} */
|
suite(`Smoke Test '${TESTS_TYPE}'`, () => {
|
||||||
let browser;
|
/** @type {playwright.Browser} */
|
||||||
|
let browser;
|
||||||
|
|
||||||
/** @type {playwright.Page} */
|
/** @type {playwright.Page} */
|
||||||
let page;
|
let page;
|
||||||
|
|
||||||
before(async () => {
|
suiteSetup(async () => {
|
||||||
console.log(`Starting browser: ${browserType}`);
|
browser = await playwright[browserType].launch({
|
||||||
browser = await playwright[browserType].launch({
|
headless: !DEBUG_TESTS,
|
||||||
headless: !DEBUG_TESTS,
|
devtools: DEBUG_TESTS && browserType === 'chromium'
|
||||||
devtools: DEBUG_TESTS
|
// slowMo: DEBUG_TESTS ? 2000 : 0
|
||||||
// slowMo: DEBUG_TESTS ? 2000 : 0
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
after(async () => {
|
suiteTeardown(async () => {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
let pageErrors = [];
|
let pageErrors = [];
|
||||||
|
|
||||||
beforeEach(async () => {
|
setup(async () => {
|
||||||
pageErrors = [];
|
pageErrors = [];
|
||||||
page = await browser.newPage({
|
page = await browser.newPage({
|
||||||
viewport: {
|
viewport: {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600
|
height: 600
|
||||||
|
}
|
||||||
|
});
|
||||||
|
page.on('pageerror', (e) => {
|
||||||
|
console.log(e);
|
||||||
|
pageErrors.push(e);
|
||||||
|
});
|
||||||
|
const response = await page.goto(URL);
|
||||||
|
assert.ok(!!response);
|
||||||
|
assert.strictEqual(response.status(), 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
teardown(async () => {
|
||||||
|
for (const e of pageErrors) {
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
await page.close();
|
||||||
});
|
});
|
||||||
page.on('pageerror', (e) => {
|
|
||||||
console.log(e);
|
|
||||||
pageErrors.push(e);
|
|
||||||
});
|
|
||||||
const response = await page.goto(URL);
|
|
||||||
assert.ok(!!response);
|
|
||||||
assert.strictEqual(response.status(), 200);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
for (const e of pageErrors) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
await page.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe(`Smoke Test '${TESTS_TYPE}'`, () => {
|
|
||||||
/**
|
/**
|
||||||
* @param {string} text
|
* @param {string} text
|
||||||
* @param {string} language
|
* @param {string} language
|
||||||
|
|
@ -101,11 +100,11 @@ describe(`Smoke Test '${TESTS_TYPE}'`, () => {
|
||||||
await page.evaluate(`window.ed.focus();`);
|
await page.evaluate(`window.ed.focus();`);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('`monacoAPI` is exposed as global', async () => {
|
test('`monacoAPI` is exposed as global', async () => {
|
||||||
assert.strictEqual(await page.evaluate(`typeof monacoAPI`), 'object');
|
assert.strictEqual(await page.evaluate(`typeof monacoAPI`), 'object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to create plaintext editor', async () => {
|
test('should be able to create plaintext editor', async () => {
|
||||||
await createEditor('hello world', 'plaintext');
|
await createEditor('hello world', 'plaintext');
|
||||||
|
|
||||||
// type a link in it
|
// type a link in it
|
||||||
|
|
@ -116,14 +115,14 @@ describe(`Smoke Test '${TESTS_TYPE}'`, () => {
|
||||||
await page.waitForSelector('.detected-link');
|
await page.waitForSelector('.detected-link');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('css smoke test', async () => {
|
test('css smoke test', async () => {
|
||||||
await createEditor('.sel1 { background: red; }\\n.sel2 {}', 'css');
|
await createEditor('.sel1 { background: red; }\\n.sel2 {}', 'css');
|
||||||
|
|
||||||
// check that a squiggle appears, which indicates that the language service is up and running
|
// check that a squiggle appears, which indicates that the language service is up and running
|
||||||
await page.waitForSelector('.squiggly-warning');
|
await page.waitForSelector('.squiggly-warning');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('html smoke test', async () => {
|
test('html smoke test', async () => {
|
||||||
await createEditor('<title>hi</title>', 'html');
|
await createEditor('<title>hi</title>', 'html');
|
||||||
|
|
||||||
// trigger hover
|
// trigger hover
|
||||||
|
|
@ -137,7 +136,7 @@ describe(`Smoke Test '${TESTS_TYPE}'`, () => {
|
||||||
await page.waitForSelector(`text=The title element represents the document's title or name`);
|
await page.waitForSelector(`text=The title element represents the document's title or name`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('json smoke test', async () => {
|
test('json smoke test', async () => {
|
||||||
await createEditor('{}', 'json');
|
await createEditor('{}', 'json');
|
||||||
|
|
||||||
// trigger suggestions
|
// trigger suggestions
|
||||||
|
|
@ -149,7 +148,7 @@ describe(`Smoke Test '${TESTS_TYPE}'`, () => {
|
||||||
await page.waitForSelector(`text=$schema`);
|
await page.waitForSelector(`text=$schema`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('typescript smoke test', async () => {
|
test('typescript smoke test', async () => {
|
||||||
await createEditor('window.add', 'typescript');
|
await createEditor('window.add', 'typescript');
|
||||||
|
|
||||||
// check that a squiggle appears, which indicates that the language service is up and running
|
// check that a squiggle appears, which indicates that the language service is up and running
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue