Write Beautiful Specs with Custom Matchers
Table of Contents
- 🌩 Installation
- 📝 API
- 🕹 Usage
- 🌍 Browser Support
- 🙋🏽♂️ Getting Help
- 👀 Other Projects
- 🤓 Author
Custom Matchers make tests easier to read and produce relevant and useful messages when they fail.
By avoiding vague messages such as "expected false to be true" in favour of useful cues such as "expected 3 to be even number" and avoiding implementation noise such as
expect(cycleWheels % 2 === 0).toEqual(true) in favour of simply stating that you
npm install jasmine-expect --save-dev
bower install jasmine-expect --save-dev
Downloads are available on the releases page.
and this default set of asymmetric matchers;
Jasmine-Matchers adds the following matchers:
Embed jasmine-matchers.js after Jasmine but before your tests.
Include the following in your
And the following at the top of your test suite:
Integration is easy with the karma-jasmine-matchers plugin.
Use the Jasmine CLI and include the path to where Jasmine Matchers is installed in the
helpers array of your
TypeScript and Angular CLI Projects
If you are using TypeScript, you might want to
npm install @types/jasmine-expect --save-dev in order to prevent your IDE from complaining about the new Matchers.
Also, if you run into TypeScript compilation errors when running your tests, add
"jasmine-expect" to the
"types" array in your tests'
As an example, for an Angular CLI based project, this would be your
🌍 Browser Support
|Android||9 - 11|
|Chrome||80 - 85|
|Edge||80 - 85|
|Firefox||76 - 80|
|iOS||10 - 14|
|Safari||10 - 13|
🙋🏽♂️ Getting Help
👀 Other Projects
If you find my Open Source projects useful, please share them ❤️
ESLint Formatter featuring Git Author, Date, and Hash
Move and rename files while keeping imports up to date
Convert functions to arrow functions
Automates ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of images part of your automated build process.
Run Benchmark.js over multiple Browsers, with CI compatible output
Interactive Q&A Guides for Web and the Command Line
Manage multiple package.json files, such as in Lerna Monorepos and Yarn Workspaces
I'm Jamie Mason from Leeds in England, I began Web Design and Development in 1999 and have been Contracting and offering Consultancy as Fold Left Ltd since 2012. Who I've worked with includes Sky Sports, Sky Bet, Sky Poker, The Premier League, William Hill, Shell, Betfair, and Football Clubs including Leeds United, Spurs, West Ham, Arsenal, and more.