Updating the version of Jasmine used in karma-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’ … Read more

Why use spyOn instead of jasmine.createSpy?

The difference is that you should have a method on the object with spyOn const o = { some(): { console.log(‘spied’) } }; spyOn(o, ‘some’); while the mock method is created for your with createSpy(): const o = {}; o.some = jasmine.createSpy(‘some’); The advantage of the spyOn is that you can call the original method: … Read more

Is there a way to add a Jasmine matcher to the whole environment

Sure, you just call beforeEach() without any spec scoping at all, and add matchers there. This would globally add a toBeOfType matcher. beforeEach(function() { var matchers = { toBeOfType: function(typeString) { return typeof this.actual == typeString; } }; this.addMatchers(matchers); }); describe(‘Thing’, function() { // matchers available here. }); I’ve made a file named spec_helper.js full … Read more

Is it possible to use Jasmine’s toHaveBeenCalledWith matcher with a regular expression?

After doing some digging, I’ve discovered that Jasmine spy objects have a calls property, which in turn has a mostRecent() function. This function also has a child property args, which returns an array of call arguments. Thus, one may use the following sequence to perform a regexp match on call arguments, when one wants to … Read more

How can I get WebStorm to recognize Jasmine methods?

You can use predefined JS library stubs in Webstorm/PHPStorm/Idea Open File > Settings… Select Languages & Frameworks > JavaScript > Libraries Click on Download… Swich to TypeScript community stubs Find karma-jasmine (originally under the name jasmine) (If this does not work, try jasmine instead) Click on Download and Install I am using this setup with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)