Let's take a look at a simple assertion chain:
An assertion chain is made up of an
assert, subject (in this case
element and some chain modifier (in this case
exists). The readability
and structure of the code should be straight forward. In this example we ask
Suitest "check if the element with 'elementApiID' exists", Suitest will
then return the chain outcome meaning if the assertion passes or fails.
// Assertion chain examples: // Element - if it exists or does not await suitest.assert.element('logo').exists(); await suitest.assert.element('login').doesNot().exist(); // Cookie - if it exists and its value await suitest.assert.cookie('_ga').exists(); await suitest.assert.cookie('_gid').equals('12345'); // Network request - https url was requested await suitest.assert.networkRequest().equal('https://suite.st/docs/').wasMade();
Lear more about assertions in Suitest.
The chain resolves to no value if the assertion passes, if it is rejected
AssertionError is thrown.
Chains without the
assert assertion look just like the example below.
const elementExists = await suitest.element('elementApiID').exists();
Heads up: You can convert any evaluation chain that does not contain
assertto an assertion line by simply adding
toAssert()at the end of the chain.
These types of chains resolve to a
boolean value and if the chain passes
A couple special chains return useful values that you may want to use during testing. These chains are created without any additional chain modifiers.
cookie subject, you
can check for a particular cookie and gather its value. The value is returned as
string if the cookie is found. If it is not found then
undefiend will be
const cookieValue = await suitest.cookie('my-cookie');
you can get element properties which are returned as an
object. If the element
is not found then
undefiend will be returned.
const elementProps = await suitest.element('my-element');
the result of your expression.
const jsExpressionResult = await suitest.jsExpression('1+2');
you can check the current location of the app which is returned as a
that contains the current location.
const currentLocation = await suitest.location();