Skip to content

Instantly share code, notes, and snippets.

@hadynz
Created May 21, 2017 07:47
Show Gist options
  • Save hadynz/969d76730d36d785b2d653f8c73fd350 to your computer and use it in GitHub Desktop.
Save hadynz/969d76730d36d785b2d653f8c73fd350 to your computer and use it in GitHub Desktop.
Pact JS blog post example - Given statement
const pactProvider = require('...');
module.exports = function steps() {
this.Given(/^That a user accesses arrives at our amazing app’s homepage$/, () => {
pactProvider.addInteraction({
state: 'querying a movie api service',
uponReceiving: 'a request to search for a given movie',
withRequest: {
method: 'GET',
path: '/',
query: { t: 'titanic', r: 'json' },
headers: {
'Accept': 'application/json, text/plain, */*'
}
},
willRespondWith: {
status: 200,
headers: { 'Content-Type': 'application/json' },
body: {
'Title': 'Stubbed Titanic',
'Year': '1997',
'Genre': 'Drama, Romance',
'Director': 'James Cameron',
'Actors': 'Leonardo DiCaprio, Kate Winslet, Billy Zane, Kathy Bates'
// ...
}
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment