业力有初始化钩子吗? [英] Does Karma have an initialization hook?

查看:99
本文介绍了业力有初始化钩子吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Karma (0.12)是否具有钩子,我可以使用该钩子在运行测试之前执行一些初始化?

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

推荐答案

使用业力0.10时,我已执行以下操作:

With karma 0.10 I've done the following:

  • 创建了一个helper.js文件,该文件已添加到因果配置中的JS列表中

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

  • 这篇关于业力有初始化钩子吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆