I am testing a registration flow in one of my specs. It is a long example, testing a multiple step wizard, with over 20 expect(page).to
.
When one of my early expectation is failing, chances are that the following expectation won't work. For example if an expectation fails in the first step of the registration, the user will not be able to go to the second step. As a result every following step will also fail.
With my current configuration (in particular --fail-fast
), the example will be run until the end, even if one expectation is failing at step 1.
Furthermore, it appears that the screenshot is taken at the end of the example, not after the failed expectation. So I have no idea of what the page looks like just after the failure.
I am missing something ?
While you don't have to religously follow "One expectionation per example." you're obviously overdoing it here. This is BDD - not beatnik poetry.
Break the long example up into multiple examples. Because that helps you have tests that fail for a specific reason, and drives you to focus on a specific behavior at a time.
Even if you're testing a user flow that can still be broken down into a set of steps.
You can use shared contexts or to share setup between context blocks. By crafting the test setup wisely you can also setup the state so that one example starts where the other one left off.