

Skip or Only Run a Test with JavaScript Mocha
source link: https://davidwalsh.name/skip-or-only-run-a-test-with-javascript-mocha
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Skip or Only Run a Test with JavaScript Mocha
Whenever I start to feel anxiety about a big change I'm making, I start writing more unit tests. I'll write down my fear and then write a test that attacks, and eventually relaxes, that fear. There are two actions that I've been frequently using with test writing: skipping all but one test or single tests.
Skip a Test
Oftentimes I will create tests with empty bodies so that I don't forget to write them. To skip a test which is incomplete or known to fail, you can use xit
:
xit('does the thing I want', () => { });
Once the test is complete or ready to be applied, you can change xit
back to it
.
Run a Single Test
To run only a single test with the Mocha test framework, use it.only
:
it.only('does the thing I want', () => { });
it.only
is especially helpful if you have a large test suite and just want the result of a work-in-progress test quickly.
Let's be honest: writing tests isn't very fun. Like taking your cousin to the school dance or changing a diaper. But test writing is important enough to save yourself, and more importantly, your users, from disaster.
Recommend
-
60
Testing is what everyone should be taking care of while deploying their awesome apps for production. It’s necessary to test applications before deploying as it helps us to ensure that apps met…
-
7
Test your Leaflet applications with MochaTest your Leaflet applications with Mocha Fri 29 March 2013Pretty much like n1k0, I feel like I had learned Javascript thr...
-
3
Mocha- A Rich JavaScript Framework. Reading Time: 4 minutes When I have started using postman and design my first framework, I have got to know that postman uses Mocha as an internal JavaScript framework to exec...
-
4
Conversation Again closes #7319 Description of the problem and...
-
5
How to test APIs using supertest, mocha and chai? What is supertest? How do I test APIs? How do I perform end to end testing of APIs using supertest? How do I create an automation t...
-
10
-
8
the fun, simple, flexible JavaScript test frameworksimple, flexible, funMocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynch...
-
6
About Mocha's Tests All assertions should be made using unexpected, unless there's a good reason not to. Exceptions include: Testing diff output. Mocha generat...
-
5
Welcome! Today we'll be creating a REST API (https://www.ibm.com/cloud/learn/rest-apis) using Node.js (https://nodejs.or...
-
9
Running specific test cases in Jasmine or MochaI recently was working on writing end-to-end test cases using protractor on a project. Everything was working fine until the number of test cases increased to a lot and running the...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK