jialeee17
jialeee17

Reputation: 843

What is assertion methods?

I'm learning AVAJS recently. One thing that sounds kind of abstract to me is 'assertion methods', or simply assertion. For example:

enter image description here

What is it, or what it actually does in programming. I'm looking for some easy-understanding docs to read up. Any recommendations?

Upvotes: 2

Views: 92

Answers (1)

slebetman
slebetman

Reputation: 113926

In most javascript test frameworks (including ava) assertion methods are simply functions that throws an error if the asserted condition is not met.

For example the method:

t.true(x, "x must be true");

will simply throw an error if the value of x is 1 or "hello" or false etc. As long as the value of x is not true t.true() will throw an error.

The way most js test frameworks work is to catch all thrown errors and output a nice report.

Upvotes: 1

Related Questions