Skip to content

Commit

Permalink
feat: 🎸 make endpoints base path configurable
Browse files Browse the repository at this point in the history
✅ Closes: #34
  • Loading branch information
mdasberg committed Jul 8, 2020
1 parent 01cc910 commit 86dbb6b
Show file tree
Hide file tree
Showing 9 changed files with 1,118 additions and 2,993 deletions.
178 changes: 100 additions & 78 deletions itest/wdio-v5/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions itest/wdio-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"wdio-local": "wdio test/wdio.local.conf.js"
},
"devDependencies": {
"@ng-apimock/core": "2.0.1",
"@ng-apimock/core": "2.1.0",
"@ng-apimock/test-application": "1.0.17",
"@types/cucumber": "6.0.1",
"@types/fs-extra": "9.0.1",
Expand All @@ -26,7 +26,7 @@
"ts-node": "8.10.2"
},
"dependencies": {
"@ng-apimock/base-client": "1.0.16"
"@ng-apimock/base-client": "2.0.0"
},
"peerDependencies": {
"webdriverio": "5.*"
Expand Down
434 changes: 201 additions & 233 deletions itest/wdio-v6/package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions itest/wdio-v6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"wdio-local": "wdio test/wdio.local.conf.js"
},
"devDependencies": {
"@ng-apimock/core": "2.0.1",
"@ng-apimock/core": "2.1.0",
"@ng-apimock/test-application": "1.0.17",
"@types/cucumber": "6.0.1",
"@types/fs-extra": "9.0.1",
"@wdio/cli": "6.1.17",
"@wdio/cucumber-framework": "6.1.18",
"@wdio/local-runner": "6.1.17",
"@wdio/cli": "6.1.25",
"@wdio/cucumber-framework": "6.1.22",
"@wdio/local-runner": "6.1.25",
"@wdio/sauce-service": "6.1.16",
"cucumber": "6.0.5",
"cucumberjs-junitxml": "1.0.0",
Expand All @@ -25,7 +25,7 @@
"ts-node": "8.10.2"
},
"dependencies": {
"@ng-apimock/base-client": "1.0.16"
"@ng-apimock/base-client": "2.0.0"
},
"peerDependencies": {
"webdriverio": "6.*"
Expand Down
3,457 changes: 789 additions & 2,668 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@commitlint/cli": "9.0.1",
"@commitlint/config-conventional": "9.0.1",
"@ng-apimock/core": "2.0.1",
"@ng-apimock/core": "2.1.0",
"@ng-apimock/test-application": "1.0.17",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/commit-analyzer": "8.0.1",
Expand Down Expand Up @@ -69,7 +69,7 @@
"typescript": "3.9.6"
},
"dependencies": {
"@ng-apimock/base-client": "1.0.16"
"@ng-apimock/base-client": "2.0.0"
},
"peerDependencies": {
"webdriverio": ">=5.*"
Expand Down
9 changes: 8 additions & 1 deletion src/webdriverio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare const browser: any;

export default class NgApimockService {
baseUrl: string;
basePath: string;
globalName: string;

constructor(options: any) {
Expand All @@ -13,6 +14,9 @@ export default class NgApimockService {
this.baseUrl = (options && options.baseUrl)
? options.baseUrl
: browser.config.baseUrl;
this.basePath = (options && options.basePath)
? options.basePath
: undefined;
}

/**
Expand All @@ -22,7 +26,10 @@ export default class NgApimockService {
* @param {Array.<String>} specs List of spec file paths that are to be run
*/
async before(capabilities: any): Promise<any> {
const plugin = new WebdriverIOClient(this.baseUrl);
const plugin = new WebdriverIOClient({
baseUrl: this.baseUrl,
basePath: this.basePath
});
(global as any)[this.globalName] = plugin;
await plugin.setNgApimockCookie();
}
Expand Down
9 changes: 8 additions & 1 deletion src/webdriverio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('WebdriverIOClient', () => {
resolveFn = jest.fn();
rejectFn = jest.fn();

client = new WebdriverIOClient('http://localhost:9000');
client = new WebdriverIOClient({ baseUrl: 'http://localhost:9000' });
});

describe('constructor', () => {
Expand All @@ -35,6 +35,13 @@ describe('WebdriverIOClient', () => {
});
});

describe('constructor custom path', () => {
it('sets the baseUrl', () => {
client = new WebdriverIOClient({ baseUrl: 'http://localhost:9000', basePath: 'myapimock' });
expect(client.baseUrl).toBe('http://localhost:9000/myapimock');
});
});

describe('openUrl', () => {
it('opens the url', async () => {
await client.openUrl('url');
Expand Down
6 changes: 3 additions & 3 deletions src/webdriverio.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BaseClient } from '@ng-apimock/base-client';
import { BaseClient, Configuration } from '@ng-apimock/base-client';

declare const browser: any;

/** Webdriver.io client for apimock. */
export class WebdriverIOClient extends BaseClient {
/** Constructor. */
constructor(baseUrl: string) {
super(baseUrl);
constructor(configuration: Configuration) {
super(configuration);
}

/** {@inheritDoc}. */
Expand Down

0 comments on commit 86dbb6b

Please sign in to comment.