Pact-js: Provider state parameters not implemented

Created on 4 Oct 2019  路  5Comments  路  Source: pact-foundation/pact-js

Software versions

  • OS: Windows 10
  • Consumer Pact library: @pact-foundation/[email protected]
  • Provider Pact library: does not matter
  • Node Version: v10.15.3

Expected behaviour

The state parameters can be passed, like at pact 3 specification
https://github.com/pact-foundation/pact-specification/tree/version-3#allow-multiple-provider-states-with-parameters

Actual behaviour

A provider state can be defined by string only.

Steps to reproduce

See the interface used to define an interaction that it can only receive a string for provider state
https://github.com/pact-foundation/pact-js/blob/3d66117c5b3ba0f2f15c9b29f5651c4eab1217cb/src/dsl/interaction.ts#L28

Relevant log files

none

I am in a project which used to be consisted of Java services only which have defined many providers with parameters. With pact-js I cannot reuse these providers.

documentation enhancement v3

Most helpful comment

As Beth said. But also, you could have two separate tests and states

e.g.

You don't need a state parameter to do this.

All 5 comments

Thanks. We know this is lacking as it is a v3 feature. I'm going to create a separate issue later tonight to track the v3 implementation, but work is already underway (see the v3 branch).

@mefellows thanks a lot!

Is there any way to work around this with the v2 specification?

Example:
The consumer test registers a new user using her email address [email protected]. The provider state setup function must execute a query to make sure that the email address does not exist yet.

The better way to handle that solution is that the datasources should all be cleared at the start of the provider state set up call. Then you would know that it does not exist.

As Beth said. But also, you could have two separate tests and states

e.g.

You don't need a state parameter to do this.

Was this page helpful?
0 / 5 - 0 ratings