Skip to content

Commit

Permalink
feat(normalization): async normalization methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Feb 24, 2018
1 parent 2b03562 commit ad0b356
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/record-scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ async function recordScenario ({request, scenario}) {
if (Array.isArray(scenario)) {
// if scenario is an array of request options, send requests sequentially
await scenario.reduce(async (promise, step) => {
let response

try {
await promise
response = await promise
} catch (error) {
// don’t fail on 4xx errors, they are valid fixtures
if (error.response.status >= 500) {
throw error
}

response = error.response
}

if (typeof step === 'function') {
return request(step(response))
}

return request(step)
Expand Down

0 comments on commit ad0b356

Please sign in to comment.