How to: run some tests consecutively
I would like to write a series of tests that would cover the following scenario (simplified for the sake of shorter post):
- user visits the login page
- user logs in and sees the products page
- user opens a product detail page
- user adds the product to the shopping cart
- user visits the checkout page
As far as I can tell, all of the tests are being run in parallel, so the checkout page will always be empty, because the test that adds the item to the cart has not yet finished running, as well as the user might not yet be logged in, since the login test might have not finished yet.
I would like to somehow group tests into "phases" and within each phase they can run in parallel. Is there a good way to approach this? My initial idea is to just create multiple .json test scenarios (one for each "phase"), then write a script that would run backstop cli command for each of the phases and wait for it to finish. The different "phases" could communicate with each other by writing data that needs to be shared between the tests to a file in the tests folder.
How would I go about "merging" the individual reports into one?
Is there a better way altogether to handle such cases?
Try setting asyncCaptureLimit: 0
https://github.com/garris/BackstopJS#capturing-screens-in-parallel
Sorry for the late reply, I fell into a rabbit hole and just came back to this now :/.
Thank you for pointing me in the right direction.
This worked like a charm and I ended up making one onReadyScript that is triggered on the first scenario and after doing the login procedure it writes the content of localStorage to a file on hard drive and then in all other tests in the onBeforeScript I'm looking for presence of that file and if it exists reading the content from it and setting it to localStorage. Is it a good idea to extend on this approach and just keep writing (overwriting) to that file after scenarios that modify localStorage in ways that would be useful in the future scenarios or is there a better/cleaner way to approach this?
Bonus question (I'm guessing it's not supported but asking anyway): Is there a way to change asyncCaptureLimit between/after certain scenarios, such that some scenarios could be run in parallel. e.g. the first scenario that does the login would be run with asyncCaptureLimit :0, then the next 5 scenarios that are just opening pages that do not modify the state in any way could be run in parallel (with asyncCaptureLimit : 5) and then the next ones again back to some other value?
You can just create two config files. One config file has one scenario which sets your local cookies. The second config has all your tests. Then run them sequentially from the command line.
Makes perfect sense. Thank you for your help and an awesome library 💯