Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to run a single mocha test?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 551
    Comment on it

    When working in mocha, oftenly you don't want to run all the test cases. Mocha provides you the feature to specify which exactly you want to run.

    Running a single test file

    Using mocha-cli you can easily run a single. This can be accomplished with the grep option when running the mocha command.

    Syntax:

    $ mocha --grep users.js
    
    or
    
    $ mocha test users.js


    Running a single test

    If you want to run a single test you can use the .only() method:-

    it.only(function () {
      // this test will run
    });
    it(function () {
      // this test will be skipped
    });

    Skipping a test

    If you need to skip a test case, you can use the .skip() method like as follows:

    it.skip(function () {
      // this test will be skipped
    });
    it(function () {
      // this test will be executed
    });

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: