- Tags:: [[Flood Element]] [[Flood (company)]] [[Load Testing]]
- Date Created: [[2020-09-08]]
- URL: https://element.flood.io/docs/guides/script#stepif
- `step.if()` is actually a [conditional step]([[Flood Element conditional steps]]) that runs when a set condition is fulfilled; however, it can also be used to run a teardown step at the end of the test.
- This can only be used as a teardown step if the total number of iterations for the test is known. The approach is to count the number of iterations and then run actions only on the last iteration. This approach is quite limited.
- `step.if()` can be used to simulate certain [load distributions]([[Load distribution]])
- ```javascript
step.if(
() => percentage < 21,
'20%',
async (browser) => {
console.log('Do this action 20% of the time.')
},
)```
-