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

查看:142
本文介绍了更新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?

我已经安装了 Karma https://github.com/karma-runner/karma-jasmine =noreferrer> karma-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.js bower.json karma.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 插件实际上安装了 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 测试框架的适配器,我有点意外< a href =https://github.com/karma-runner/karma-jasmine =noreferrer> 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.

推荐答案

您可以通过运行以下规范来了解您正在使用的茉莉花版本:

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)

你可以尝试修改插件,以便可以升级并向业力发送拉取请求(请参阅 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天全站免登陆