Categories
JavaScript Answers

How to run only one test with Cypress and JavaScript?

Spread the love

Sometimes, we want to run only one test with Cypress and JavaScript.

In this article, we’ll look at how to run only one test with Cypress and JavaScript.

How to run only one test with Cypress and JavaScript?

To run only one test with Cypress and JavaScript, we can set the --space option or use the it.only method.

For instance, we run

cypress run --spec path/to/file.spec.js

to run the tests in path/to/file.spec.js.

In our test, we write

it.only("only run this one", () => {
  // ...
});

it("not this one", () => {});

to run only the first test by calling creating the test with it.only.

Conclusion

To run only one test with Cypress and JavaScript, we can set the --space option or use the it.only method.

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 *