What is the difference between `test()` and `it()` in Jest?

Beginner

Answer

There is no functional difference between test() and it() - they are aliases of each other. Both are used to define individual test cases:

test('should add two numbers', () => {
  expect(add(2, 3)).toBe(5);
});

it('should add two numbers', () => {
  expect(add(2, 3)).toBe(5);
});

The choice between them is often stylistic. it() reads more naturally in BDD (Behavior Driven Development) style, while test() is more explicit about its purpose.