Last active
August 29, 2015 14:02
-
-
Save DavidFrahm/f473b9a4d1369dbff993 to your computer and use it in GitHub Desktop.
Jasmine 1.3.x custom matchers, both global and scoped to a specific describe suite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
describe("Jasmine", function () { | |
describe("custom matchers", function () { | |
beforeEach(function () { | |
this.addMatchers({ | |
toBeSomethingBeforeEachInSpec: function (expected) { | |
return this.actual.something === "something"; | |
} | |
}); | |
}); | |
it("should work with custom matchers in this spec", function () { | |
var myObject = {something: "something"}; | |
expect(myObject).toBeSomethingBeforeEachInSpec('param, in spec'); | |
}); | |
it("should work with global custom matchers", function () { | |
var myObject = {something: "something"}; | |
expect(myObject).toBeSomethingBeforeEachGlobal('param, in global'); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
beforeEach(function () { | |
this.addMatchers({ | |
toBeSomethingBeforeEachGlobal: function (expected) { | |
return this.actual.something === "something"; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment