Your First Test

Let's take a look at some tests using Jest.

Jest test

A Jest test uses the it function, which takes two arguments. The first argument is the name of the test. By convention, it’s written to be read with the word “it”. So, below, we see it('sums numbers', ...) reads like “it sums numbers”. We should try to keep the test names as readable and meaningful as we can. The test results will show this string together with the test result and the time it took. The second argument is a function, typically written using the arrow notation.

Try it yourself

We’ve written a simple test below. Run it in the widget and we’ll see a passing test.

Get hands-on with 1200+ tech skills courses.