How can I confirm what version of Jasmine I'm using?

会有一股神秘感。 提交于 2019-11-29 11:07:09

问题


If I recall there is a command in Jasmine that will log the exact version of Jasmine I'm running to the console, but I can't remember what it is. I am positive I have seen this before somewhere, and now that I actually need it I can't find it anywhere. Does anyone know what it is?


Edit: The posted solution of using jasmine.getEnv().versionString() isn't working - to any mods reading this, would fixing that issue be better to start as a new question, or continue here?


回答1:


To simply log the version number try:

   if (jasmine.version) { //the case for version 2.0.0
       console.log('jasmine-version:' + jasmine.version);
    }
    else { //the case for version 1.3
       console.log('jasmine-version:' + jasmine.getEnv().versionString());
    }

I use this little helper function:

 this.isJasmineV2 = function () {
        return (jasmine.version && jasmine.version.charAt(0) === "2");
        //version 1.3 uses this syntax: jasmine.getEnv().versionString()
    };



回答2:


command line command:

Detailed view:

npm view jasmine

or

Version Number:

npm view jasmine version



回答3:


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

Source: Updating the version of Jasmine used in karma-jasmine




回答4:


Judging by the code

jasmine.version

should give you the version string.




回答5:


Do above mentioned or simply go to jasmine.js file and look for function getJasmineRequireObj().version. This function is returning the version of the jasmine.



来源:https://stackoverflow.com/questions/24658007/how-can-i-confirm-what-version-of-jasmine-im-using

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