Skip to content

Allow multiple instances of mock server #133

Answered by ASaiAnudeep
samuelsantia asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @samuelsantia,

Thank you for the suggestion. With current version of pactum there is no straightforward way to run multiple instances of mock server. In the earlier versions of this library, we used to support this feature but later it was decommissioned.

For most of the use cases a single mock server is adequate to mock multiple services as most of them has unique endpoints and moreover pactum supports sophisticated matching rules to respond accurately.

const { mock } = require('pactum');

// service one interactions
mock.addInteraction({
  request: {
    method: 'GET',
    path: '/api/service-one/health'
  },
  response: {
    status: 200
  }
});

// service two interactions
mock.ad…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@samuelsantia
Comment options

Answer selected by samuelsantia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants