Upgrade Jasmine 1.3 to 2.4
Quick upgrade with those Regexp replaces
/createSpyObj/ => " jasmine.createSpyObj"
/createSpy/ => "jasmine.createSpy"
/\.andCallFake/ => ".and.callFake"
/\.andReturn/ => ".and.returnValue"
/\.andCallThrough/ => ".and.callThrough"
/toNotMatch/ => "not.toMatch"
/this.addMatchers/ => "jasmine.addMatchers"
/\.calls\[0\]\./ => ".calls.first()"
/\.calls\[(\d)\]\./ => ".calls.all()[$1]"
/\.callCount/ => ".calls.count()"
runs and waitsFor have been removed and should be replaced with function(done) / done():
https://groups.google.com/forum/#!topic/jasmine-js/Q_4lyEWrZKI
Problem with Expected {XYZ} to equal Object({XYZ})
An Asset object should
✓ get deserialized for further tests
✓ be deserialized from a serialized protobuf message
✗ find tracks, resources, and chunks by id
- Expected ({ id: 0, type: 'PROTOBUF', chunk: [ ({ id: 0 }), ({ id: 1 }) ] }) to equal Object({ id: 0, type: 'PROTOBUF', chunk: [ Object({ id: 0 }), Object({ id: 1 }) ] }).
at Object. (js/tests/lib/assets/asset_spec.js:290:22)
Solution
beforeEach(function(done) {
jasmine.addMatchers({
toStringifyEqual: function(util, customEqualityTesters) {
return {
compare: function(actual, expected) {
var result = {};
var actual_ = JSON.stringify(actual);
var expected_ = JSON.stringify(expected);
result.pass = _.isEqual(actual_, expected_);
return result;
}
}
}
});
});
Examples
Error : ReferenceError: createSpy is not defined
Solution
Replace with jasmine.createSpy
Error : On lines with .calls[0] some errors such as TypeError: Cannot read property 'args' of undefined
Solution
Replace .calls[0] with .calls.first()
Recent Comments