Does Karma have an initialization hook?

冷暖自知 提交于 2019-12-13 05:09:11

问题


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


回答1:


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();
    });
    


来源:https://stackoverflow.com/questions/22767246/does-karma-have-an-initialization-hook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!