Skip to content

Controlling when Chutzpah runs

Matthew Manela edited this page Dec 2, 2016 · 2 revisions

Chutzpah by default will control when the test framework (Mocha, QUnit, Jasmine) is ready for it to start reading available tests and test results. This typically works for most use cases however there are situations where you are doing delay loading of the test cases until some other resource is available. In this cases Chutzpah may find 0 tests since it thinks testing is done before it ever got started! To address this issue you can take control and explicitly tell Chutzpah when it tests are ready.

There are a pair of methods to use:

window.chutzpah.preventAutoStart(); - Put this at the top of a JS file that you load early. This tells Chutzpah to not automatically start recording test cases.

window.chutzpah.start() - This tells Chutzpah to start listening for tests explicitly.

Example

window.chutzpah.preventAutoStart();


// Use setTimeout to delay when the test gets loaded
// this demonstrated who Chutzpah preventAutoStart/start can be used.
setTimeout(function() {
  
  test("Some Test", function() {

    ok(true);
  });
  
  window.chutzpah.start();
}, 500);