Skip to content

Commit

Permalink
fix: throw an error when pact spec version is not set to 2
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyJones committed Mar 15, 2022
1 parent 7e9f2e7 commit 4186c22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/httpPact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export class Pact {
throw new ConfigurationError("You must specify a Provider for this pact.")
}

if (this.opts.spec !== 2) {
throw new ConfigurationError(
"Pact-js currently only supports pact spec version 2. If you need a higher version of the pact specification, you can try the beta. See instructions here: https://github.com/pact-foundation/pact-js#pact-js-v3"
)
}

setLogLevel(this.opts.logLevel as LogLevel)
serviceFactory.logLevel(this.opts.logLevel)

Expand Down
4 changes: 4 additions & 0 deletions src/pact-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export class PactWeb {

this.opts = { ...defaults, ...config } as PactWebOptionsComplete

if (this.opts.spec !== 2) {
throw new Error("Pact-web only supports pact spec version 2")
}

console.info(
`Setting up Pact using mock service on port: "${this.opts.port}"`
)
Expand Down

0 comments on commit 4186c22

Please sign in to comment.