Created
June 2, 2014 15:19
-
-
Save rentan/5099df90327e9ddae5ef to your computer and use it in GitHub Desktop.
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
var customMatchers = { | |
toStartWith: function (util, customEqualityTesters) { | |
return { | |
compare: function (actual, expected) { | |
return { pass: actual.slice (0, expected.length) === expected }; | |
} | |
}; | |
} | |
}; | |
describe ('test', function () { | |
it ('test 1', function () { | |
// it() 単位でのみ有効 | |
jasmine.addMatchers (customMatchers); | |
expect ('foobar').toStartWith ('foo'); | |
expect ('abc').not.toStartWith ('foo'); | |
}); | |
xit ('test 2', function () { | |
// ここではカスタムマッチャーが登録されてないのでエラーになる | |
expect ('foobar').toStartWith ('foo'); | |
expect ('abc').not.toStartWith ('foo'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment