Skip to content

Commit e722bfb

Browse files
Merge pull request #31 from mgrybyk/upgrade-to-v8
Upgrade to v8
2 parents db60225 + d5137a7 commit e722bfb

15 files changed

+3026
-6406
lines changed

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Use Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: "lts/*"
18+
- uses: actions/setup-java@v3
19+
with:
20+
distribution: "temurin"
21+
java-version: "17"
22+
- run: npm ci
23+
- run: HEADLESS=true npm test

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false,
4+
"trailingComma": "es5",
5+
"printWidth": 140
6+
}

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
# jest-webdriverio-standalone-boilerplate
22

3+
> WebdriverIO Jest boilerplate with Wiremock
4+
5+
## Usage
6+
7+
Make sure to have Java installed properly!
8+
39
1. install dependencies `npm ci`
410
2. run tests `npm t`
11+
12+
## Project details
13+
14+
**Project type**: `commonjs`
15+
16+
**Packages:**
17+
18+
- webdriverio@8
19+
- wdio-wiremock-service@6
20+
- expect-webdriverio@4
21+
- jest@29
22+
- typescript@4
23+
24+
Hint: if you're looking for project type `module` or typescript@5 setup please see [this](https://github.com/mgrybyk/wdio-jest-boilerplate) repo.

__tests__/test1.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { expect } from "expect-webdriverio";
2+
import { test } from "@jest/globals";
3+
14
test("WebdriverIO test 1", async () => {
25
await chrome.url("https://webdriver.io");
3-
expect(await chrome.getTitle()).toContain("WebdriverIO");
6+
await expect(chrome).toHaveTitle("WebdriverIO", { containing: true });
47
const searchButton = await chrome.$(".DocSearch-Button");
58
await searchButton.click();
69
const searchBar = await chrome.$("#docsearch-input");

__tests__/test2.spec.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

__tests__/wiremock-service.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { test } from "@jest/globals";
2+
import { expect } from "expect-webdriverio";
13
import nodeFetch, { Response } from "node-fetch";
24

35
test(`a mocked api response created using WireMock's fixtures`, async () => {
46
await chrome.url("http://localhost:8080/dummy_data");
5-
const body = await chrome.$("body");
6-
expect(await body.getText()).toEqual("this is a fixture, and it works!\n");
7+
await expect(chrome.$("body")).toHaveText("this is a fixture, and it works!");
78
});
89

910
test(`a mocked api response created using WireMock's HTTP API`, async () => {
@@ -34,6 +35,6 @@ test(`a mocked api response created using WireMock's HTTP API`, async () => {
3435

3536
await nodeFetch("http://localhost:8080/new_data")
3637
.then((res: Response) => res.json())
37-
.then((body: object) => expect(body).toEqual(expectedRes));
38+
.then((body) => expect(body).toEqual(expectedRes));
3839
});
3940
});

global.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { WiremockLauncher } from "wdio-wiremock-service/lib/launcher";
2-
import { Browser } from "webdriverio";
32

43
export declare global {
5-
var chrome: Browser<'async'>;
4+
var chrome: WebdriverIO.Browser;
65
var wiremockLauncher: WiremockLauncher;
76
}

jest.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module.exports = {
2-
preset: 'ts-jest',
2+
preset: 'ts-jest/presets/default-esm',
3+
moduleNameMapper: {
4+
'^(\\.{1,2}/.*)\\.[jt]s$': '$1',
5+
},
36
testEnvironment: 'node',
47
globalSetup: './jest.global.setup.ts',
58
globalTeardown: './jest.global.teardown.ts',

jest.global.setup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { launcher as wmLauncher } from 'wdio-wiremock-service';
1+
import { launcher as wmLauncher } from "wdio-wiremock-service";
22

3-
export default async function() {
4-
globalThis.wiremockLauncher = new wmLauncher({ rootDir: '__stubs__', port: 9090 });
3+
export default async function () {
4+
globalThis.wiremockLauncher = new wmLauncher({ rootDir: "__stubs__", port: 8080 });
55

66
await wiremockLauncher.onPrepare();
7-
};
7+
}

jest.global.teardown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export default async function() {
1+
export default async function () {
22
await globalThis.wiremockLauncher.onComplete();
3-
};
3+
}

0 commit comments

Comments
 (0)