Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is slow parameter in mocha?

When we define mochaOpts in Protractor, we define one parameter as slow. I do not understand what is the use of that parameter. I tried changing it's value but I can't see any change in test execution time.

mochaOpts: {
   reporter: 'spec',
   slow: 1000,
}
like image 622
Priyanshu Shekhar Avatar asked Oct 14 '15 06:10

Priyanshu Shekhar


People also ask

What is beforeEach in Mocha?

The beforeEach method is a feature (hook) in test libraries that you can use to set preconditions for each test. Just like the name suggests, it runs before each test in your test suite. For example, the beforeEach method will run four times in a suite with four tests.

What is Mocha timeout?

Whenever you run Mocha at the command line, it will read this file and set a timeout of 5 seconds by default. Another way which may be better depending on your situation is to set it like this in a top level describe call in your test file: describe("something", function () { this. timeout(5000); // tests... });

Are Mocha tests run in parallel?

Mocha does not run individual tests in parallel. That means if you hand Mocha a single, lonely test file, it will spawn a single worker process, and that worker process will run the file. If you only have one test file, you'll be penalized for using parallel mode. Don't do that.

What is context in Mocha?

ctx is the context in effect where the describe call appears, which happens to be the same context as this in the afterEach call. I would actually recommend not traversing Mocha's internal structures and instead doing something like: describe('main describe', function() { var prop; afterEach(function() { console.


1 Answers

According to the documentation its used for testing

-s, --slow

Specify the "slow" test threshold, defaulting to 75ms. Mocha uses this to highlight test-cases that are taking too long.

To tweak what's considered "slow", you can use the slow() method:

describe('something slow', function() {
  this.slow(10000);

  it('should take long enough for me to go make a sandwich', function() {
    // ...
  });
});
like image 64
NooBskie Avatar answered Sep 21 '22 22:09

NooBskie