Often while writing tests you have some setup work that needs to happen before tests run, and you have some finishing work that needs to happen after tests run. Flood Element provides helper functions to handle this.
Some setups need to be done before the main test begins, as a pre-condition. For example, you are going to test a web app, and in order to perform the main steps, you need to be authenticated first. In that case, you can do the authentication within
For the setup that needs to be repeated before each step, you can put it inside
Sometimes, to avoid trash data while testing on production environment, you need to do the cleaning after each step. In that case, use
After the main steps have finished, you may want to do the final cleaning work, or simply just log out to kill the session.
afterAll() is a good choice for this.
As long as
after* handlers are put inside the default test suite, they will be executed in the following order, regardless of where you put them inside the suite:
- Your test
Take the following code snippet as an example:
The output of the above code should be:
In case you have more than 1
beforeAll() in your test script, they will be executed sequentially from top to down. Similarly for