Skip to content

Commit

Permalink
feat: support user defined port/host in v3 consumer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Jul 20, 2022
1 parent cac6560 commit 8aaafe6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/v3/pact.ts
Expand Up @@ -184,10 +184,10 @@ export class PactV3 {
public async executeTest<T>(
testFn: (mockServer: V3MockServer) => Promise<T>
): Promise<T | undefined> {
const scheme = 'http';
const host = '127.0.0.1';
const scheme = this.opts.tls ? 'https' : 'http';
const host = this.opts.host || '127.0.0.1'

const port = this.pact.createMockServer(host, this.opts.port);
const port = this.pact.createMockServer(host, this.opts.port, this.opts.tls);
const server = { port, url: `${scheme}://${host}:${port}`, id: 'unknown' };
let val: T | undefined;

Expand Down
8 changes: 8 additions & 0 deletions src/v3/types.ts
Expand Up @@ -40,6 +40,14 @@ export interface PactV3Options {
* Specification version to use
*/
logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error';
/**
* Flag to identify if HTTP or HTTPs over TLS should be used (default false, HTTP)
*/
tls?: boolean;
/**
* The host to run the mock service, defaults to 127.0.0.1
*/
host?: string;
}

export interface V3ProviderState {
Expand Down

0 comments on commit 8aaafe6

Please sign in to comment.