Skip to content

Instantly share code, notes, and snippets.

@lwillmeth
Created September 20, 2019 16:27
Show Gist options
  • Save lwillmeth/9d4c157ff80fdf5e4e4a4e95c50d39f8 to your computer and use it in GitHub Desktop.
Save lwillmeth/9d4c157ff80fdf5e4e4a4e95c50d39f8 to your computer and use it in GitHub Desktop.
Example questioning the value of assertions while creating a contract
// based on https://github.com/pact-foundation/pact-js/blob/master/examples/mocha/test/get-dogs.spec.js#L40-L75
describe("get /dogs", () => {
it("returns the correct response", async () => {
await provider.addInteraction({
state: "i have a list of dogs",
uponReceiving: "a request for all dogs",
withRequest: {
method: "GET",
path: "/dogs",
headers: { Accept: "application/json" },
},
willRespondWith: {
status: 200,
headers: { "Content-Type": "application/json" },
body: EXPECTED_BODY
}
})
const urlAndPort = { url: url, port: port }
return getMeDogs(urlAndPort)
// the response is stubbed, so why bother asserting it?
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment