Categories
JavaScript Answers

How to skip one test in test file with Jest?

Spread the love

Sometimes, we want to skip one test in test file with Jest.

In this article, we’ll look at how to skip one test in test file with Jest.

How to skip one test in test file with Jest?

To skip one test in test file with Jest, we can call test.skip in our test code.

For instance, we write:

test('it is delicious', () => {
  expect(isDelicious()).toBeTruthy();
});

test.skip('it is not yellow', () => {
  expect(isYellow()).toBeFalsy();
});

to call test to create and run the first test.

And we call test.skip to skip the 2nd test.

Conclusion

To skip one test in test file with Jest, we can call test.skip in our test code.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *