Created
May 21, 2017 07:47
-
-
Save hadynz/969d76730d36d785b2d653f8c73fd350 to your computer and use it in GitHub Desktop.
Pact JS blog post example - Given statement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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