Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(finalise): warn if finalise called more than once
  • Loading branch information
mefellows committed Dec 5, 2017
1 parent 4259171 commit bc52810
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pact.ts
Expand Up @@ -28,6 +28,7 @@ export class Pact {
public server: any;
public opts: PactOptionsComplete;
public mockService: MockService;
private finalized: boolean;

constructor(config: PactOptions) {
const defaults = {
Expand Down Expand Up @@ -131,6 +132,12 @@ export class Pact {
* @returns {Promise}
*/
finalize(): Promise<void> {
if (this.finalized) {
logger.warn('finalize() has already been called, this is probably a logic error in your test setup. ' +
'In the future this will be an error.');
};
this.finalized = true;

return this.mockService.writePact()
.then(() => this.server.delete())
.catch((err: Error) => {
Expand Down

0 comments on commit bc52810

Please sign in to comment.