更新 karma-jasmine 中使用的 Jasmine 版本 [英] Updating the version of Jasmine used in karma-jasmine

查看:31
本文介绍了更新 karma-jasmine 中使用的 Jasmine 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • How can I update the version of Jasmine used when running Jasmine via Karma using the karma-jasmine plugin?
  • Will Jasmine only get updated whenever the karma-jasmine plugin integrates a newer version of Jasmine, or can I point the karma-jasmine plugin to a newer version of Jasmine?
  • What version of Jasmine is installed by karma-jasmine?

我已经安装了 Karmakarma-jasmine 使用 Yeoman 如下:

I've installed Karma and karma-jasmine using Yeoman as follows:

$ npm install -g generator-angular
$ mkdir myapp && cd $_
$ yo angular

鉴于 myapp/bower.json 没有列出 Jasmine作为 Bower 安装的前端包之一,但 myapp/karma.conf.js 列出 Jasmine 作为默认的测试框架,我很惊讶命令 grunt test 起作用了.(Gruntfile.jsbower.jsonkarma.conf.js 文件都是作为 yo angular 的一部分创建的 脚手架过程.)

Given that myapp/bower.json didn't list Jasmine as one of the Bower installed front-end packages but myapp/karma.conf.js listed Jasmine as the default testing framework, I was surprised the command grunt test worked. (The Gruntfile.js, bower.json, and karma.conf.js files were all created as part of the yo angular scaffolding process.)

在仔细检查 myapp/node_modules 包后,我意识到 karma-jasmine 并不指向单独安装 Jasmine.karma-jasmine 插件实际上安装了 茉莉花:

Upon closer inspection of the myapp/node_modules packages, I realized that karma-jasmine doesn't point to a separate installation of Jasmine. The karma-jasmine plugin actually installs Jasmine:

▼ myapp/
  ▼ karma_jasmine/
    ▼ lib/
        adapter.js
        index.js
        jasmine.js

鉴于 karma-jasmine 说它是一个适配器 用于 Jasmine 测试框架,"我有点惊讶 karma-jasmine 不需要我们安装 Jasmine 分开.

Given that karma-jasmine says it is an "adapter for the Jasmine testing framework," I was a little surprised that karma-jasmine didn't require us to install Jasmine separately.

这里是使用的各种包版本:

Here are the various package versions used:

  • Karma: "~0.10.8" per myapp/package.json contents
  • karma-jasmine: "~0.1.4" per myapp/package.json contents
  • Yeoman: "1.0.6" per npm list -g | grep yo command results
  • Jasmine: Unknown but based on a few diffs, I'm almost wondering if karma-jasmine includes a customized version of Jasmine to work with Karma.

推荐答案

你可以通过运行以下 Spec 了解你正在使用的 jasmine 版本:

You can know the jasmine version you are using by running the following Spec:

describe('Test to print out jasmine version', function() {
  it('prints jasmine version', function() {
    console.log('jasmine-version:');
    console.log(jasmine.version || (jasmine.getEnv().versionString && jasmine.getEnv().versionString()));
  });
});

然后在您的控制台或浏览器中检查业力输出.它应该是这样的:

and then checking the karma output in your console or browser. It should be something like:

LOG: 'jasmine-version:'
LOG: '2.3.4'

正如您已经发现的,jasmine 库包含在 jasmine-runner 插件中.您可以在插件的源代码中找到加载此文件的确切位置:https://github.com/karma-runner/karma-jasmine/blob/master/lib/index.js(第7行)

The jasmine library is included in the jasmine-runner plugin as you've already found out. You can find the exact place where this file is loaded in the source code of the plugin: https://github.com/karma-runner/karma-jasmine/blob/master/lib/index.js (line 7)

您可以尝试修改插件以便可以升级并向 karma 发送拉取请求(请参阅 http://karma-runner.github.io/0.10/dev/contributing.html)

You can try to modify the plugin so that an upgrade is possible and send a pull request to karma (see http://karma-runner.github.io/0.10/dev/contributing.html)

这篇关于更新 karma-jasmine 中使用的 Jasmine 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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