Skip to content

Commit 7e766ab

Browse files
committed
Adjust smoke test which also uses mocha
1 parent 41ded74 commit 7e766ab

File tree

4 files changed

+47
-48
lines changed

4 files changed

+47
-48
lines changed

.mocharc.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"delay": true,
3-
"ui": "tdd",
4-
"spec": "test/unit/all.js"
3+
"ui": "tdd"
54
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"simpleserver": "node ./build/simpleserver",
2020
"smoketest-debug": "node ./test/smoke/runner.js --debug-tests",
2121
"smoketest": "node ./test/smoke/runner.js",
22-
"test": "mocha",
22+
"test": "mocha test/unit/all.js",
2323
"typedoc": "cd website/typedoc && \"../../node_modules/.bin/typedoc\" --options ./typedoc.json",
2424
"watch": "tsc -w -p ./src"
2525
},

test/smoke/runner.js

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function runTest(type, browser) {
6161
[
6262
path.join(REPO_ROOT, 'node_modules/mocha/bin/mocha'),
6363
'test/smoke/*.test.js',
64+
'--no-delay',
6465
'--headless',
6566
'--timeout',
6667
'20000'

test/smoke/smoke.test.js

+44-45
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,51 @@ const URL =
1818
? `http://127.0.0.1:${PORT}/test/smoke/amd.html`
1919
: `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`;
2020

21-
/** @type {playwright.Browser} */
22-
let browser;
23-
24-
/** @type {playwright.Page} */
25-
let page;
26-
27-
before(async () => {
28-
console.log(`Starting browser: ${browserType}`);
29-
browser = await playwright[browserType].launch({
30-
headless: !DEBUG_TESTS,
31-
devtools: DEBUG_TESTS
32-
// slowMo: DEBUG_TESTS ? 2000 : 0
21+
suite(`Smoke Test '${TESTS_TYPE}'`, () => {
22+
/** @type {playwright.Browser} */
23+
let browser;
24+
25+
/** @type {playwright.Page} */
26+
let page;
27+
28+
suiteSetup(async () => {
29+
browser = await playwright[browserType].launch({
30+
headless: !DEBUG_TESTS,
31+
devtools: DEBUG_TESTS && browserType === 'chromium'
32+
// slowMo: DEBUG_TESTS ? 2000 : 0
33+
});
3334
});
34-
});
3535

36-
after(async () => {
37-
await browser.close();
38-
});
36+
suiteTeardown(async () => {
37+
await browser.close();
38+
});
3939

40-
let pageErrors = [];
40+
let pageErrors = [];
4141

42-
beforeEach(async () => {
43-
pageErrors = [];
44-
page = await browser.newPage({
45-
viewport: {
46-
width: 800,
47-
height: 600
48-
}
49-
});
50-
page.on('pageerror', (e) => {
51-
console.log(e);
52-
pageErrors.push(e);
42+
setup(async () => {
43+
pageErrors = [];
44+
page = await browser.newPage({
45+
viewport: {
46+
width: 800,
47+
height: 600
48+
}
49+
});
50+
page.on('pageerror', (e) => {
51+
console.log(e);
52+
pageErrors.push(e);
53+
});
54+
const response = await page.goto(URL);
55+
assert.ok(!!response);
56+
assert.strictEqual(response.status(), 200);
5357
});
54-
const response = await page.goto(URL);
55-
assert.ok(!!response);
56-
assert.strictEqual(response.status(), 200);
57-
});
5858

59-
afterEach(async () => {
60-
for (const e of pageErrors) {
61-
throw e;
62-
}
63-
await page.close();
64-
});
59+
teardown(async () => {
60+
for (const e of pageErrors) {
61+
throw e;
62+
}
63+
await page.close();
64+
});
6565

66-
describe(`Smoke Test '${TESTS_TYPE}'`, () => {
6766
/**
6867
* @param {string} text
6968
* @param {string} language
@@ -101,11 +100,11 @@ describe(`Smoke Test '${TESTS_TYPE}'`, () => {
101100
await page.evaluate(`window.ed.focus();`);
102101
}
103102

104-
it('`monacoAPI` is exposed as global', async () => {
103+
test('`monacoAPI` is exposed as global', async () => {
105104
assert.strictEqual(await page.evaluate(`typeof monacoAPI`), 'object');
106105
});
107106

108-
it('should be able to create plaintext editor', async () => {
107+
test('should be able to create plaintext editor', async () => {
109108
await createEditor('hello world', 'plaintext');
110109

111110
// type a link in it
@@ -116,14 +115,14 @@ describe(`Smoke Test '${TESTS_TYPE}'`, () => {
116115
await page.waitForSelector('.detected-link');
117116
});
118117

119-
it('css smoke test', async () => {
118+
test('css smoke test', async () => {
120119
await createEditor('.sel1 { background: red; }\\n.sel2 {}', 'css');
121120

122121
// check that a squiggle appears, which indicates that the language service is up and running
123122
await page.waitForSelector('.squiggly-warning');
124123
});
125124

126-
it('html smoke test', async () => {
125+
test('html smoke test', async () => {
127126
await createEditor('<title>hi</title>', 'html');
128127

129128
// trigger hover
@@ -137,7 +136,7 @@ describe(`Smoke Test '${TESTS_TYPE}'`, () => {
137136
await page.waitForSelector(`text=The title element represents the document's title or name`);
138137
});
139138

140-
it('json smoke test', async () => {
139+
test('json smoke test', async () => {
141140
await createEditor('{}', 'json');
142141

143142
// trigger suggestions
@@ -149,7 +148,7 @@ describe(`Smoke Test '${TESTS_TYPE}'`, () => {
149148
await page.waitForSelector(`text=$schema`);
150149
});
151150

152-
it('typescript smoke test', async () => {
151+
test('typescript smoke test', async () => {
153152
await createEditor('window.add', 'typescript');
154153

155154
// check that a squiggle appears, which indicates that the language service is up and running

0 commit comments

Comments
 (0)