Function perseus::checkpoint
source · [−]pub fn checkpoint(name: &str)
Expand description
Marks a checkpoint in the code and alerts any tests that it’s been reached by creating an element that represents it. The preferred
solution would be emitting a DOM event, but the WebDriver specification currently doesn’t support waiting on those (go figure). This
will only create a custom element if the __PERSEUS_TESTING
JS global variable is set to true
.
This adds a <div id="__perseus_checkpoint-<event-name>" />
to the <div id="__perseus_checkpoints"></div>
element, creating the
latter if it doesn’t exist. Each checkpoint must have a unique name, and if the same checkpoint is executed twice, it’ll be added
with a -<number>
after it, starting from 0
. In this way, we have a functional checkpoints queue for signalling to test code!
Note that the checkpoint queue is NOT cleared on subsequent loads.
Note: this is not just for internal usage, it’s highly recommended that you use this for your own checkpoints as well! Just make
sure your tests don’t conflict with any internal Perseus checkpoint names (preferably prefix yours with custom-
or the like, as
Perseus’ checkpoints may change at any time, but won’t ever use that namespace).
WARNING: your checkpoint names must not include hyphens! This will result in a panic!
.