Skip to content

Commit

Permalink
Merge pull request #233 from pact-foundation/fix/issue-231
Browse files Browse the repository at this point in the history
fix(interaction-failure): clear interactions on any verify()
  • Loading branch information
mefellows authored Oct 17, 2018
2 parents ac27a1e + fbc5ac0 commit e375894
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pact.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe("Pact", () => {
const verifyPromise = b.verify();
return Promise.all([
expect(verifyPromise).to.eventually.be.rejectedWith(Error),
verifyPromise.catch(() => expect(removeInteractionsStub).to.callCount(0)),
verifyPromise.catch(() => expect(removeInteractionsStub).to.callCount(1)),
]);
});
});
Expand Down
7 changes: 5 additions & 2 deletions src/pact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,18 @@ export class Pact {
return this.mockService.verify()
.then(() => this.mockService.removeInteractions())
.catch((e: any) => {

// Properly format the error
/* tslint:disable: no-console */
console.error("");
console.error(clc.red("Pact verification failed!"));
console.error(clc.red(e));
/* tslint:enable: */

throw new Error("Pact verification failed - expected interactions did not match actual.");
});
return this.mockService.removeInteractions().then(() => {
throw new Error("Pact verification failed - expected interactions did not match actual.");
})
})
}

/**
Expand Down

0 comments on commit e375894

Please sign in to comment.