Skip to content

Commit

Permalink
test: fail prepare fixtures script if fixtures fail to install deps o…
Browse files Browse the repository at this point in the history
…r build a fixture
  • Loading branch information
pieh committed Jan 27, 2025
1 parent 5a2d6fa commit fe86e9f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/prepare.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ const promises = fixtures.map((fixture) =>
operation: 'revert',
})
}
if (output.exitCode !== 0) {
const errorMessage = `[${fixture}] Failed to install dependencies or build a fixture`
console.error(errorMessage)
throw new Error(errorMessage)
}
fixtureList.delete(fixture)
})
}).finally(() => {
Expand All @@ -91,5 +96,22 @@ const promises = fixtures.map((fixture) =>
}
}),
)
await Promise.allSettled(promises)
const prepareFixturesResults = await Promise.allSettled(promises)
const failedFixturesErrors = prepareFixturesResults
.map((promise) => {
if (promise.status === 'rejected') {
return promise.reason
}
return null
})
.filter(Boolean)

if (failedFixturesErrors.length > 0) {
console.error('🚨 Some fixtures failed to prepare:')
for (const error of failedFixturesErrors) {
console.error(error)
}
process.exit(1)
}

console.log('🎉 All fixtures prepared')

0 comments on commit fe86e9f

Please sign in to comment.