Skip to content

Commit ffef80f

Browse files
authored
feat: 🎸 make endpoints base path configurable (#35)
✅ Closes: #34
1 parent 01cc910 commit ffef80f

9 files changed

+1118
-2993
lines changed

‎itest/wdio-v5/package-lock.json

+100-78
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎itest/wdio-v5/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"wdio-local": "wdio test/wdio.local.conf.js"
1010
},
1111
"devDependencies": {
12-
"@ng-apimock/core": "2.0.1",
12+
"@ng-apimock/core": "2.1.0",
1313
"@ng-apimock/test-application": "1.0.17",
1414
"@types/cucumber": "6.0.1",
1515
"@types/fs-extra": "9.0.1",
@@ -26,7 +26,7 @@
2626
"ts-node": "8.10.2"
2727
},
2828
"dependencies": {
29-
"@ng-apimock/base-client": "1.0.16"
29+
"@ng-apimock/base-client": "2.0.0"
3030
},
3131
"peerDependencies": {
3232
"webdriverio": "5.*"

‎itest/wdio-v6/package-lock.json

+201-233
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎itest/wdio-v6/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"wdio-local": "wdio test/wdio.local.conf.js"
1010
},
1111
"devDependencies": {
12-
"@ng-apimock/core": "2.0.1",
12+
"@ng-apimock/core": "2.1.0",
1313
"@ng-apimock/test-application": "1.0.17",
1414
"@types/cucumber": "6.0.1",
1515
"@types/fs-extra": "9.0.1",
16-
"@wdio/cli": "6.1.17",
17-
"@wdio/cucumber-framework": "6.1.18",
18-
"@wdio/local-runner": "6.1.17",
16+
"@wdio/cli": "6.1.25",
17+
"@wdio/cucumber-framework": "6.1.22",
18+
"@wdio/local-runner": "6.1.25",
1919
"@wdio/sauce-service": "6.1.16",
2020
"cucumber": "6.0.5",
2121
"cucumberjs-junitxml": "1.0.0",
@@ -25,7 +25,7 @@
2525
"ts-node": "8.10.2"
2626
},
2727
"dependencies": {
28-
"@ng-apimock/base-client": "1.0.16"
28+
"@ng-apimock/base-client": "2.0.0"
2929
},
3030
"peerDependencies": {
3131
"webdriverio": "6.*"

‎package-lock.json

+789-2,668
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"devDependencies": {
4242
"@commitlint/cli": "9.0.1",
4343
"@commitlint/config-conventional": "9.0.1",
44-
"@ng-apimock/core": "2.0.1",
44+
"@ng-apimock/core": "2.1.0",
4545
"@ng-apimock/test-application": "1.0.17",
4646
"@semantic-release/changelog": "5.0.1",
4747
"@semantic-release/commit-analyzer": "8.0.1",
@@ -69,7 +69,7 @@
6969
"typescript": "3.9.6"
7070
},
7171
"dependencies": {
72-
"@ng-apimock/base-client": "1.0.16"
72+
"@ng-apimock/base-client": "2.0.0"
7373
},
7474
"peerDependencies": {
7575
"webdriverio": ">=5.*"

‎src/webdriverio.service.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ declare const browser: any;
44

55
export default class NgApimockService {
66
baseUrl: string;
7+
basePath: string;
78
globalName: string;
89

910
constructor(options: any) {
@@ -13,6 +14,9 @@ export default class NgApimockService {
1314
this.baseUrl = (options && options.baseUrl)
1415
? options.baseUrl
1516
: browser.config.baseUrl;
17+
this.basePath = (options && options.basePath)
18+
? options.basePath
19+
: undefined;
1620
}
1721

1822
/**
@@ -22,7 +26,10 @@ export default class NgApimockService {
2226
* @param {Array.<String>} specs List of spec file paths that are to be run
2327
*/
2428
async before(capabilities: any): Promise<any> {
25-
const plugin = new WebdriverIOClient(this.baseUrl);
29+
const plugin = new WebdriverIOClient({
30+
baseUrl: this.baseUrl,
31+
basePath: this.basePath
32+
});
2633
(global as any)[this.globalName] = plugin;
2734
await plugin.setNgApimockCookie();
2835
}

‎src/webdriverio.spec.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('WebdriverIOClient', () => {
2626
resolveFn = jest.fn();
2727
rejectFn = jest.fn();
2828

29-
client = new WebdriverIOClient('http://localhost:9000');
29+
client = new WebdriverIOClient({ baseUrl: 'http://localhost:9000' });
3030
});
3131

3232
describe('constructor', () => {
@@ -35,6 +35,13 @@ describe('WebdriverIOClient', () => {
3535
});
3636
});
3737

38+
describe('constructor custom path', () => {
39+
it('sets the baseUrl', () => {
40+
client = new WebdriverIOClient({ baseUrl: 'http://localhost:9000', basePath: 'myapimock' });
41+
expect(client.baseUrl).toBe('http://localhost:9000/myapimock');
42+
});
43+
});
44+
3845
describe('openUrl', () => {
3946
it('opens the url', async () => {
4047
await client.openUrl('url');

‎src/webdriverio.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { BaseClient } from '@ng-apimock/base-client';
1+
import { BaseClient, Configuration } from '@ng-apimock/base-client';
22

33
declare const browser: any;
44

55
/** Webdriver.io client for apimock. */
66
export class WebdriverIOClient extends BaseClient {
77
/** Constructor. */
8-
constructor(baseUrl: string) {
9-
super(baseUrl);
8+
constructor(configuration: Configuration) {
9+
super(configuration);
1010
}
1111

1212
/** {@inheritDoc}. */

0 commit comments

Comments
 (0)