Somewhat strange, this is not basic functionality.
You can add your own match as follows:
JasmineExtensions.js
yourGlobal.addExtraMatchers = function () { var addMatcher = function (name, func) { func.name = name; jasmine.matchers[name] = func; }; addMatcher("toBeGreaterThanOrEqualTo", function () { return { compare: function (actual, expected) { return { pass: actual >= expected }; } }; } ); };
In fact, you define a constructor for your match - this is a function that returns a conjugation object.
Turn it on before downloading. Base sockets load at boot time.
Your html file should look like this:
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script> <script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script> <script type="text/javascript" src="Tests/JasmineExtensions.js"></script> <script type="text/javascript" src="lib/jasmine-2.0.0/boot.js"></script>
Then in your boot.js add a call to add matches after defining jasmine, but before jasmine.getEnv (). Getting env is actually a (slightly mistakenly named) setup call.
Matches get set up in a call to setupCoreMatchers in the Env constructor.
window.jasmine = jasmineRequire.core(jasmineRequire); yourGlobal.addExtraMatchers(); jasmineRequire.html(jasmine); var env = jasmine.getEnv();
They show another way to add custom matches in test cases, but the way it works is to recreate the match before each individual test using beforeEach . It seems pretty horrible, so I thought I would go this route.
JonnyRaa Jun 27 '14 at 15:26 2014-06-27 15:26
source share