Assertion scripts are code snippets that verify if conditions or assumptions in software are true, commonly used in testing to automate checks for expected behavior. They raise errors if assertions fail, ensuring software correctness.
Apidog has built-in ChaiJS as an assertion library. Below is an example of commonly used assertion test scripts. View the documentation, ChaiJS expect BDD library, for more examples.
Assert that the target string contains another string#
Assert that the target is strictly equal to (===) a value#
If the deep flag is on, the assert target is the value.
When you turn on the deep flag to use equal and property assertions, the flag will allow subsequent assertions to compare key-value pairs of objects recursively instead of comparing the objects themselves.
Assert that the depth is equal to a value, equivalent to deep.equal(value)#