In this article, we’ll look at what is the difference between ‘it’ and ‘test’ in Jest.
What is the difference between ‘it’ and ‘test’ in Jest?
it
and test
are the same since it
is an alias of test
according to https://jestjs.io/docs/api#testname-fn-timeout
They exist to make the code read like English.
For instance, we write:
describe('yourModule', () => {
test('if it does this thing', () => {});
test('if it does the other thing', () => {});
});
or
describe('yourModule', () => {
it('should do this thing', () => {});
it('should do the other thing', () => {});
});
and they do the same thing.
Conclusion
it
and test
are the same since it
is an alias of test
according to https://jestjs.io/docs/api#testname-fn-timeout
They exist to make the code read like English.