Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Jul 11, 2019
1 parent 872a559 commit a4115ef
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
5 changes: 5 additions & 0 deletions src/smoke/src/areas/testExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class TestExplorer {
}
}
@retry(RetryMax5Seconds)
public async waitUntilIconVisible() {
const visible = await this.isIconVisible();
assert.ok(visible);
}
@retry(RetryMax5Seconds)
public async waitUntilVisible() {
const visible = await this.isVisible();
assert.ok(visible);
Expand Down
42 changes: 21 additions & 21 deletions src/smoke/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,24 @@ AfterAll({ timeout: maxHookTimeout }, async function () {
};
});

/*
Capture screenshots after every step.
*/
(setDefinitionFunctionWrapper as any)(function (fn: Function) {
async function captureScreenshot() {
try {
const name = `After_${new Date().getTime()}`.replace(/[^a-z0-9\-]/gi, '_');
// Ignore errors, as its possible app hasn't started.
await context.app.captureScreenshot(name).catch(noop);
} catch { noop(); }
}
return async function (this: {}) {
const result = fn.apply(this, [].slice.call(arguments));
if (result.then) {
return (result as Promise<any>).finally(captureScreenshot);
} else {
await captureScreenshot();
return result;
}
};
});
// /*
// Capture screenshots after every step.
// */
// (setDefinitionFunctionWrapper as any)(function (fn: Function) {
// async function captureScreenshot() {
// try {
// const name = `After_${new Date().getTime()}`.replace(/[^a-z0-9\-]/gi, '_');
// // Ignore errors, as its possible app hasn't started.
// await context.app.captureScreenshot(name).catch(noop);
// } catch { noop(); }
// }
// return async function (this: {}) {
// const result = fn.apply(this, [].slice.call(arguments));
// if (result.then) {
// return (result as Promise<any>).finally(captureScreenshot);
// } else {
// await captureScreenshot();
// return result;
// }
// };
// });
6 changes: 3 additions & 3 deletions src/smoke/src/steps/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const statusToIconMapping: Record<TestNodeStatus, string> = {
};

Then('the test explorer icon will be visible', async () => {
await context.app.workbench.testExplorer.isIconVisible();
await context.app.workbench.testExplorer.waitUntilIconVisible();
});

// Surely tests can't take more than 30s to get discovered.
Expand All @@ -34,7 +34,7 @@ When('I wait for tests to complete running', async () => {
await context.app.workbench.testExplorer.waitForTestsToStop();
});

Then('there are {int} nodes in the test explorer', async (expectedCount: number) => {
Then('there are {int} nodes in the test explorer', CucumberRetryMax5Seconds, async (expectedCount: number) => {
const count = await context.app.workbench.testExplorer.getNodeCount();
expect(count).to.equal(expectedCount);
});
Expand All @@ -47,7 +47,7 @@ async function getNumberOfNodesWithIcon(icon: string): Promise<number> {
const elements = await context.app.workbench.testExplorer.getNodeIcons();
return elements.filter(ele => ele.attributes.style.includes(icon)).length;
}
Then('{int} nodes in the test explorer have a status of "{word}"', async (count: number, status: TestNodeStatus) => {
Then('{int} nodes in the test explorer have a status of "{word}"', CucumberRetryMax5Seconds, async (count: number, status: TestNodeStatus) => {
const nodeCount = await getNumberOfNodesWithIcon(statusToIconMapping[status]);
expect(nodeCount).to.equal(count);
});
Expand Down

0 comments on commit a4115ef

Please sign in to comment.