Skip to content

Commit 8e0d8cf

Browse files
committed
Provide more info about test failures thrugh catching more webdriverio exceptions.
1 parent e0d0a4e commit 8e0d8cf

23 files changed

Lines changed: 208 additions & 91 deletions

test/smoke/src/areas/common.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ export class CommonActions {
2727
public async addSetting(setting: string, value: string): Promise<any> {
2828
await this.spectron.command('workbench.action.openGlobalSettings');
2929
await this.spectron.wait();
30-
await this.spectron.client.leftClick('.editable-preferences-editor-container .view-lines', 1, 1, false);
30+
try {
31+
await this.spectron.client.leftClick('.editable-preferences-editor-container .view-lines', 1, 1, false);
32+
} catch (e) {
33+
return Promise.reject('Failed to select settings editor to add a setting.');
34+
}
3135
await this.spectron.client.keys(['ArrowDown', 'NULL', 'ArrowDown', 'NULL'], false);
3236
await this.spectron.wait();
3337
await this.spectron.client.keys(`"${setting}": "${value}"`);
@@ -122,7 +126,12 @@ export class CommonActions {
122126
}
123127
selector += '"]';
124128

125-
await this.spectron.waitFor(this.spectron.client.doubleClick, selector);
129+
try {
130+
await this.spectron.waitFor(this.spectron.client.doubleClick, selector);
131+
} catch (e) {
132+
return Promise.reject(`Cannot fine ${fileName} in a viewlet.`);
133+
}
134+
126135
return this.spectron.wait();
127136
}
128137

test/smoke/src/areas/configuration-views.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ export class ConfigurationView {
1818
// noop
1919
}
2020

21-
public getEditorLineNumbers(): any {
22-
return this.spectron.client.elements('.line-numbers');
21+
public async getEditorLineNumbers(): Promise<any> {
22+
const lineNumbers = await this.spectron.client.elements('.line-numbers');
23+
24+
return lineNumbers.value.length;
2325
}
2426

2527
public enterKeybindingsView(): any {

test/smoke/src/areas/extensions.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,33 @@ export class Extensions {
2525
const searchBoxSelector = `${this.extensionsViewletSelector} .search-box`;
2626

2727
await this.spectron.client.clearElement(searchBoxSelector);
28-
await this.spectron.client.click(searchBoxSelector, false);
28+
try {
29+
await this.spectron.client.click(searchBoxSelector, false);
30+
} catch (e) {
31+
return Promise.reject('Failed to click on search box in extensions viewlet.');
32+
}
2933
await this.spectron.client.keys(name);
34+
3035
return this.spectron.client.keys(['NULL', 'Enter', 'NULL']);
3136
}
3237

3338
public async installExtension(name: string): Promise<any> {
3439
const extensionListSelector = `${this.extensionsViewletSelector} .monaco-list-rows`;
3540
this.viewletExtensionIndex = await this.getExtensionIndex(name, extensionListSelector);
36-
return this.spectron.client.click(`${extensionListSelector}>:nth-child(${this.viewletExtensionIndex}) .extension .extension-action.install`);
41+
42+
try {
43+
return this.spectron.client.click(`${extensionListSelector}>:nth-child(${this.viewletExtensionIndex}) .extension .extension-action.install`);
44+
} catch (e) {
45+
return Promise.reject('Failed to click on install button for selected extension.');
46+
}
3747
}
3848

3949
public getExtensionReloadText(): Promise<any> {
40-
return this.spectron.waitFor(this.spectron.client.getText, `${this.extensionsViewletSelector} .monaco-list-rows>:nth-child(${this.viewletExtensionIndex}) .extension .extension-action.reload`);
50+
try {
51+
return this.spectron.waitFor(this.spectron.client.getText, `${this.extensionsViewletSelector} .monaco-list-rows>:nth-child(${this.viewletExtensionIndex}) .extension .extension-action.reload`);
52+
} catch (e) {
53+
return Promise.reject('Reload was not prompted for an installed extension.');
54+
}
4155
}
4256

4357
public async selectMinimalIconsTheme(): Promise<any> {
@@ -49,23 +63,27 @@ export class Extensions {
4963
}
5064

5165
public async verifyFolderIconAppearance(): Promise<any> {
52-
return this.spectron.waitFor(this.spectron.client.getHTML, 'style[class="contributedIconTheme"]');
66+
try {
67+
return this.spectron.waitFor(this.spectron.client.getHTML, 'style[class="contributedIconTheme"]');
68+
} catch (e) {
69+
return Promise.reject('Failed to validate extension contribution.');
70+
}
5371
}
5472

5573
private getExtensionIndex(name: string, extensionListSelector: string): Promise<number> {
5674
return new Promise(async (res, rej) => {
5775
const html = await this.spectron.waitFor(this.spectron.client.getHTML, extensionListSelector);
5876
let extensionIndex: number = 0;
5977
let extension: boolean;
60-
var domelems:string[] = [];
61-
var parser = new htmlparser.Parser({
78+
let tags: string[] = [];
79+
let parser = new htmlparser.Parser({
6280
onopentag: function (name, attribs) {
6381
if (name === 'div' && attribs.class === 'extension') {
6482
extensionIndex++;
6583
extension = true;
6684
}
6785
if (extension) {
68-
domelems.push(name);
86+
tags.push(name);
6987
}
7088
},
7189
ontext: function (text) {
@@ -75,17 +93,17 @@ export class Extensions {
7593
},
7694
onclosetag: function (name) {
7795
if (extension) {
78-
domelems.pop();
96+
tags.pop();
7997
}
80-
if (extension && domelems.length === 0) {
98+
if (extension && tags.length === 0) {
8199
extension = false;
82100
}
83101
},
84102
onend: function () {
85103
if (extensionIndex === 0) {
86-
rej(`${name} extension was not found.`);
104+
return rej(`${name} extension was not found.`);
87105
}
88-
res(extensionIndex);
106+
return res(extensionIndex);
89107
}
90108
});
91109
parser.write(html);

test/smoke/src/areas/git.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,29 @@ export class Git {
105105
}
106106

107107
public focusOnCommitBox(): Promise<any> {
108-
return this.spectron.client.click('div[id="workbench.view.scm"] textarea');
108+
try {
109+
return this.spectron.client.click('div[id="workbench.view.scm"] textarea');
110+
} catch (e) {
111+
return Promise.reject('Failed to focus on commit box: ' + e);
112+
}
109113
}
110114

111115
public async pressCommit(): Promise<any> {
112-
await this.spectron.client.click('.action-label.icon.contrib-cmd-icon-10');
116+
try {
117+
await this.spectron.client.click('.action-label.icon.contrib-cmd-icon-10');
118+
} catch (e) {
119+
return Promise.reject('Failed to press commit: ' + e);
120+
}
121+
113122
return this.spectron.wait();
114123
}
115124

116125
public getOutgoingChanges(): Promise<string> {
117-
return this.spectron.client.getText('a[title="Synchronize Changes"]');
126+
try {
127+
return this.spectron.client.getText('a[title="Synchronize Changes"]');
128+
} catch (e) {
129+
return Promise.reject(`Failed to obtain 'synchronize changes' title value from the status bar.`);
130+
}
118131
}
119132

120133
private getFirstChangeIndex(changeClass: string, selector: string): Promise<number> {

test/smoke/src/areas/integrated-terminal.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ export class IntegratedTerminal {
2828

2929
const rows = await this.spectron.client.elements(`${selector} div`);
3030
for (let i = 0; i < rows.value.length; i++) {
31-
const rowText = await this.spectron.client.getText(`${selector}>:nth-child(${i + 1})`);
31+
let rowText;
32+
try {
33+
rowText = await this.spectron.client.getText(`${selector}>:nth-child(${i+1})`);
34+
} catch (e) {
35+
return Promise.reject(`Failed to obtain text from line ${i+1} from the terminal.`);
36+
}
3237
if (rowText.trim() === result) {
3338
return true;
3439
}

test/smoke/src/areas/javascript-debug.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ export class JavaScriptDebug {
3535
}
3636

3737
public setBreakpointOnLine(lineNumber: number): Promise<any> {
38-
return this.spectron.client.leftClick(`${this.sidebarSelector}>:nth-child(${lineNumber})`, 5, 5);
38+
try {
39+
return this.spectron.client.leftClick(`${this.sidebarSelector}>:nth-child(${lineNumber})`, 5, 5);
40+
} catch (e) {
41+
return Promise.reject('Setting breakpoint failed: ' + e);
42+
}
3943
}
4044

4145
public async verifyBreakpointOnLine(lineNumber: number): Promise<any> {

test/smoke/src/areas/javascript.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ export class JavaScript {
6666
this.foldLine = await this.getLineIndexOfFirstFoldableElement(`.margin-view-overlays`);
6767
this.foldSelector = `.margin-view-overlays>:nth-child(${this.foldLine})`;
6868

69-
return this.spectron.client.click(`${this.foldSelector} .cldr.folding`);
69+
try {
70+
return this.spectron.client.click(`${this.foldSelector} .cldr.folding`);
71+
} catch (e) {
72+
return Promise.reject('Clicking on fold element failed ' + e);
73+
}
7074
}
7175

7276
public async getFirstCommentFoldedIcon(): Promise<any> {
@@ -82,19 +86,27 @@ export class JavaScript {
8286
return Promise.reject('Folded line was not set, most likely because fold was not toggled initially.');
8387
}
8488

85-
return this.spectron.client.getText(`.margin-view-overlays>:nth-child(${this.foldLine+1}) .line-numbers`);
89+
return this.spectron.client.getText(`.margin-view-overlays>:nth-child(${this.foldLine + 1}) .line-numbers`);
8690
}
8791

8892
public async goToExpressDefinition(): Promise<any> {
8993
await this.setExpressVarSelector();
90-
await this.spectron.client.click(this.expressVarSelector);
94+
try {
95+
await this.spectron.client.click(this.expressVarSelector);
96+
} catch (e) {
97+
return Promise.reject(`Clicking on express variable failed: ` + e);
98+
}
9199

92100
return this.spectron.command('editor.action.goToDeclaration');
93101
}
94102

95103
public async peekExpressDefinition(): Promise<any> {
96104
await this.setExpressVarSelector();
97-
await this.spectron.client.click(this.expressVarSelector);
105+
try {
106+
await this.spectron.client.click(this.expressVarSelector);
107+
} catch (e) {
108+
return Promise.reject('Clicking on express variable failed: ' + e);
109+
}
98110

99111
return this.spectron.command('editor.action.previewDeclaration');
100112
}

test/smoke/src/areas/localization.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ export class Localization {
1919
}
2020

2121
public async getOpenEditorsText(): Promise<string> {
22-
const explorerTitles = await this.spectron.client.getText('div[id="workbench.view.explorer"] .title span');
22+
let explorerTitles;
23+
try {
24+
explorerTitles = await this.spectron.client.getText('div[id="workbench.view.explorer"] .title span');
25+
} catch (e) {
26+
return Promise.reject('Failed to get span of title in explorer viewlet.');
27+
}
28+
2329
return explorerTitles[0];
2430
}
2531

@@ -45,11 +51,19 @@ export class Localization {
4551
}
4652

4753
public getOpenedViewletTitle(): Promise<string> {
48-
return this.spectron.client.getText('div[id="workbench.parts.sidebar"] .title-label span');
54+
try {
55+
return this.spectron.client.getText('div[id="workbench.parts.sidebar"] .title-label span');
56+
} catch (e) {
57+
return Promise.reject('Failed to get span of title label in explorer viewlet.');
58+
}
4959
}
5060

5161
public getExtensionsSearchPlaceholder(): Promise<string> {
52-
return this.spectron.client.getAttribute('div[id="workbench.view.extensions"] .search-box', 'placeholder');
62+
try {
63+
return this.spectron.client.getAttribute('div[id="workbench.view.extensions"] .search-box', 'placeholder');
64+
} catch (e) {
65+
return Promise.reject('Failed to add attribute for extensi');
66+
}
5367
}
5468

5569
}

test/smoke/src/areas/search.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,54 @@ export class Search {
2121
}
2222

2323
public setReplaceText(text: string): any {
24-
return this.spectron.client.setValue('.viewlet .input[title="Replace"]', text);
24+
try {
25+
return this.spectron.client.setValue('.viewlet .input[title="Replace"]', text);
26+
} catch (e) {
27+
return Promise.reject('Cannot set replace input in the viewlet: ' + e);
28+
}
2529
}
2630

2731
public replaceFirstMatch(): any {
28-
return this.spectron.client.click('.monaco-tree-rows.show-twisties .action-label.icon.action-replace-all');
32+
try {
33+
return this.spectron.client.click('.monaco-tree-rows.show-twisties .action-label.icon.action-replace-all');
34+
} catch (e) {
35+
return Promise.reject('Cannot replace the search first match: ' + e);
36+
}
2937
}
3038

3139
public getResultText(): any {
3240
return this.spectron.waitFor(this.spectron.client.getText, '.search-viewlet .message>p');
3341
}
3442

3543
public toggleSearchDetails(): any {
36-
return this.spectron.client.click('.query-details .more');
44+
try {
45+
return this.spectron.client.click('.query-details .more');
46+
} catch (e) {
47+
return Promise.reject('Toggling search details failed: ' + e);
48+
}
3749
}
3850

3951
public toggleReplace(): any {
40-
return this.spectron.client.click('.monaco-button.toggle-replace-button.collapse');
52+
try {
53+
return this.spectron.client.click('.monaco-button.toggle-replace-button.collapse');
54+
} catch (e) {
55+
return Promise.reject('Toggling replace failed: ' + e);
56+
}
4157
}
4258

4359
public hoverOverResultCount(): any {
44-
return this.spectron.waitFor(this.spectron.client.moveToObject, '.monaco-count-badge');
60+
try {
61+
return this.spectron.waitFor(this.spectron.client.moveToObject, '.monaco-count-badge');
62+
} catch (e) {
63+
return Promise.reject('Hovering over result count failed: ' + e);
64+
}
4565
}
4666

4767
public dismissResult(): any {
48-
return this.spectron.client.click('.action-label.icon.action-remove');
68+
try {
69+
return this.spectron.client.click('.action-label.icon.action-remove');
70+
} catch (e) {
71+
return Promise.reject('Clicking on dismissing result failed: ' + e);
72+
}
4973
}
5074
}

test/smoke/src/areas/statusbar.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ export class StatusBar {
4141
throw new Error('No such element in the status bar defined.');
4242
}
4343

44-
return this.spectron.client.click(selector);
44+
try {
45+
return this.spectron.client.click(selector);
46+
} catch (e) {
47+
return Promise.reject(`Clicking on status bar element ${selector} failed.`);
48+
}
4549
}
4650

4751
public async getProblemsView(): Promise<any> {

0 commit comments

Comments
 (0)