mercredi 20 janvier 2021

How can I organize TestCafé tests into multiple steps?

I am testing a large project with long scenarios (some with more than 100 interactions with webpage). I would like to break them down into shorter steps that run in sequence (like in Mocha) but I don't know how to do that.

Example: In a single test, I would like to run

fixture('test1')

test('test1', async (t) => {
  ...login
  ...createSubAccount
  ...modifySubAccount
  ...activateSubAccount
})

where each of the steps would show in console and in report. Right now, the only thing I know how to do is to put each step into its own test() context, but that means that if e.g. createSubAccount fails, modifySubAccount and activateSubAccount will still run (even though the workflow already failed). Also, there is the unhappy part that each test() clears the browser (but I can deal with that).

In short: How can I split the tests in a way that if a single substep of fixture fails, the whole fixture fails immediately? Or similar thing, but for test()?

Also, I don't want the whole pipeline to end on the first test failure, as would happen with --stopOnFirstFail flag - I want to run all the tests, to find which are failing.

Aucun commentaire:

Enregistrer un commentaire