Skip to content

Commit 190f9a8

Browse files
Merge pull request #14 from erwinheitzman/release-1.4.0
update to webdriverio v7
2 parents ccab6a8 + 1989999 commit 190f9a8

File tree

6 files changed

+294
-313
lines changed

6 files changed

+294
-313
lines changed

__tests__/async.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { remote } from 'webdriverio';
2-
import { config } from '../wdio.conf';
1+
import { remote, Browser } from "webdriverio";
2+
import { config } from "../wdio.conf";
33

4-
let browser: WebdriverIO.BrowserObject;
4+
let browser: Browser<"async">;
55

66
beforeAll(async () => {
77
browser = await remote(config);
@@ -11,11 +11,13 @@ afterAll(async () => {
1111
await browser.deleteSession();
1212
});
1313

14-
test('asynchronous WebdriverIO test', async () => {
15-
await browser.url('https://webdriver.io');
16-
expect(await browser.getTitle()).toContain('WebdriverIO');
17-
const searchBar = await browser.$('#search_input_react');
18-
await searchBar.setValue('click');
19-
const suggestions = await browser.$('.aa-suggestions');
14+
test("asynchronous WebdriverIO test", async () => {
15+
await browser.url("https://webdriver.io");
16+
expect(await browser.getTitle()).toContain("WebdriverIO");
17+
const searchButton = await browser.$(".DocSearch-Button");
18+
await searchButton.click();
19+
const searchBar = await browser.$("#docsearch-input");
20+
await searchBar.setValue("click");
21+
const suggestions = await browser.$(".DocSearch-Hit");
2022
await suggestions.waitForExist();
2123
});

__tests__/sync.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { remote } from 'webdriverio';
2-
import { config } from '../wdio.conf';
3-
import sync from '@wdio/sync';
1+
import { remote, Browser } from "webdriverio";
2+
import { config } from "../wdio.conf";
3+
import sync from "@wdio/sync";
44

5-
let browser: WebdriverIO.BrowserObject;
5+
let browser: Browser<"async">;
66

77
beforeAll(async () => {
88
browser = await remote(config);
@@ -12,11 +12,16 @@ afterAll(async () => {
1212
await browser.deleteSession();
1313
});
1414

15-
test('synchronous WebdriverIO test', () => (sync as any)(() => {
16-
browser.url('https://webdriver.io');
17-
expect(browser.getTitle()).toContain('WebdriverIO');
18-
// @ts-ignore
19-
browser.$('#search_input_react').setValue('click');
20-
// @ts-ignore
21-
browser.$('.aa-suggestions').waitForExist();
22-
}));
15+
/**
16+
* "any" is used here because we are mixing both sync and async in one setup
17+
* this is because this boilerplate is meant to showcase how webdriverio
18+
* can be utilised
19+
*/
20+
test("synchronous WebdriverIO test", () =>
21+
sync(() => {
22+
browser.url("https://webdriver.io");
23+
expect(browser.getTitle()).toContain("WebdriverIO");
24+
(browser.$(".DocSearch-Button") as any).click();
25+
(browser.$("#docsearch-input") as any).setValue("click");
26+
(browser.$(".DocSearch-Hit") as any).waitForExist();
27+
}));

__tests__/wiremock-service.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { remote } from 'webdriverio';
2-
import { config } from '../wdio.conf';
3-
import nodeFetch from 'node-fetch';
1+
import { Browser, remote } from "webdriverio";
2+
import { config } from "../wdio.conf";
3+
import nodeFetch from "node-fetch";
44

5-
let browser: WebdriverIO.BrowserObject;
5+
let browser: Browser<"async">;
66

77
beforeAll(async () => {
88
browser = await remote(config);
@@ -13,36 +13,39 @@ afterAll(async () => {
1313
});
1414

1515
test(`a mocked api response created using WireMock's fixtures`, async () => {
16-
await browser.url('http://localhost:8080/dummy_data');
17-
const body = await browser.$('body');
18-
expect(await body.getText()).toEqual('this is a fixture, and it works!\n');
16+
await browser.url("http://localhost:8080/dummy_data");
17+
const body = await browser.$("body");
18+
expect(await body.getText()).toEqual("this is a fixture, and it works!\n");
1919
});
2020

2121
test(`a mocked api response created using WireMock's HTTP API`, async () => {
2222
const expectedRes = {
2323
dummy: [
2424
{
25-
data: 'example'
26-
}
27-
]
25+
data: "example",
26+
},
27+
],
2828
};
2929

3030
const body = JSON.stringify({
3131
request: {
32-
method: 'GET',
33-
url: '/new_data'
32+
method: "GET",
33+
url: "/new_data",
3434
},
3535
response: {
3636
status: 200,
37-
jsonBody: expectedRes
38-
}
37+
jsonBody: expectedRes,
38+
},
3939
});
4040

4141
await browser.call(async () => {
42-
await nodeFetch('http://localhost:8080/__admin/mappings/new', { method: 'POST', body });
42+
await nodeFetch("http://localhost:8080/__admin/mappings/new", {
43+
method: "POST",
44+
body,
45+
});
4346

44-
await nodeFetch('http://localhost:8080/new_data')
47+
await nodeFetch("http://localhost:8080/new_data")
4548
.then((res: any) => res.json())
4649
.then((body: any) => expect(body).toEqual(expectedRes));
47-
});
50+
});
4851
});

0 commit comments

Comments
 (0)