Question

Does Karma (0.12) have a hook which I can use to perform some initialization before running tests?

Était-ce utile?

La solution

With karma 0.10 I've done the following:

  • created an helper.js file which has been added to the JS list in the karma configuration

    module.exports = function(config) {
      config.set({
        ...
        files: [
          // Helping Libraries
          'vendor/jquery.js',
          'helpers/helper.js',
          ...
        ],
        ...
    
  • the content of the helper is:

    window.__karma__.loaded = function() {};
    
    $(function () {
      // do my stuff in here
    
      // at the end of my stuff start karma:
      window.__karma__.start();
    });
    
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top