Skip to content

Commit

Permalink
fix(verifier): allow to use progress formatter during verification (#189
Browse files Browse the repository at this point in the history
)

* fix(verifier): Allow to use progress formatter during verification
* chore(verifier): Re-enable RspecJunitFormatter as an option for formatter
* docs(verifier): Document format option
  • Loading branch information
vgrigoruk authored and mefellows committed Oct 10, 2019
1 parent 185f456 commit 2571725
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ pact.verifyPacts({
| `customProviderHeaders` | false | array | Header(s) to add to provider state set up and pact verification | | `requests`. eg 'Authorization: Basic cGFjdDpwYWN0'. |
| `providerVersion` | false | string | Provider version, required to publish verification result to Broker. Optional otherwise. |
| `timeout` | false | number | The duration in ms we should wait to confirm verification process was successful. Defaults to 30000. |
| `format` | false | string | What format the verification results are printed in. Options are `json`, `xml`, `progress` and `RspecJunitFormatter` (which is a synonym for `xml`) |

### Pact Broker Publishing

Expand Down
7 changes: 7 additions & 0 deletions src/verifier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ describe('Verifier Spec', () => {
format: 'json',
} as any),
).to.not.throw(Error);
expect(() =>
verifierFactory({
providerBaseUrl: 'http://localhost',
pactUrls: ['http://idontexist'],
format: 'progress',
} as any),
).to.not.throw(Error);
});

it('should throw an error with anything but a string', () => {
Expand Down
9 changes: 5 additions & 4 deletions src/verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ export class Verifier {

if (options.format) {
checkTypes.assert.string(options.format);
checkTypes.assert.match(options.format, /^(xml|json)$/i);
options.format =
options.format.toLowerCase() === 'xml' ? 'RspecJunitFormatter' : 'json';
checkTypes.assert.match(options.format, /^(xml|json|progress)$/i);
if (options.format.toLowerCase() === 'xml') {
options.format = 'RspecJunitFormatter';
}
}

if (options.out) {
Expand Down Expand Up @@ -216,6 +217,6 @@ export interface VerifierOptions {
timeout?: number;
tags?: string[];
monkeypatch?: string;
format?: 'json' | 'RspecJunitFormatter';
format?: 'json' | 'xml' | 'progress' | 'RspecJunitFormatter';
out?: string;
}

0 comments on commit 2571725

Please sign in to comment.