{"id":13493401,"url":"https://github.com/JamieMason/Jasmine-Matchers","last_synced_at":"2025-03-28T11:32:41.647Z","repository":{"id":2468445,"uuid":"3440875","full_name":"JamieMason/Jasmine-Matchers","owner":"JamieMason","description":"Write Beautiful Specs with Custom Matchers for Jest and Jasmine","archived":false,"fork":false,"pushed_at":"2023-12-04T18:47:20.000Z","size":2423,"stargazers_count":586,"open_issues_count":14,"forks_count":83,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-10-29T17:35:07.177Z","etag":null,"topics":["asymmetric-matchers","bdd","jasmine","javascript","javascript-tests","jest","karma","tdd","test-matchers","testing","unit-testing"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/jasmine-expect","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JamieMason.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE-MIT","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"JamieMason"}},"created_at":"2012-02-14T15:14:55.000Z","updated_at":"2024-05-31T04:08:14.000Z","dependencies_parsed_at":"2022-08-31T00:01:55.992Z","dependency_job_id":"e8159ecf-fe61-4958-9687-4fe44f6b5f23","html_url":"https://github.com/JamieMason/Jasmine-Matchers","commit_stats":{"total_commits":330,"total_committers":15,"mean_commits":22.0,"dds":0.3727272727272727,"last_synced_commit":"36da146ad95562c47fee4701e373b727f2c3db56"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2FJasmine-Matchers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2FJasmine-Matchers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2FJasmine-Matchers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JamieMason%2FJasmine-Matchers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JamieMason","download_url":"https://codeload.github.com/JamieMason/Jasmine-Matchers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237977776,"owners_count":19396388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asymmetric-matchers","bdd","jasmine","javascript","javascript-tests","jest","karma","tdd","test-matchers","testing","unit-testing"],"created_at":"2024-07-31T19:01:14.854Z","updated_at":"2025-03-28T11:32:41.326Z","avatar_url":"https://github.com/JamieMason.png","language":"JavaScript","funding_links":["https://github.com/sponsors/JamieMason"],"categories":["JavaScript"],"sub_categories":[],"readme":"# Jasmine-Matchers\n\n\u003e Write Beautiful Specs with Custom Matchers\n\n[![NPM version](http://img.shields.io/npm/v/jasmine-expect.svg?style=flat-square)](https://www.npmjs.com/package/jasmine-expect) [![NPM downloads](http://img.shields.io/npm/dm/jasmine-expect.svg?style=flat-square)](https://www.npmjs.com/package/jasmine-expect) [![Build Status](http://img.shields.io/travis/JamieMason/Jasmine-Matchers/master.svg?style=flat-square)](https://travis-ci.org/JamieMason/Jasmine-Matchers) [![Maintainability](https://api.codeclimate.com/v1/badges/8b2cd248837df1409c4d/maintainability)](https://codeclimate.com/github/JamieMason/Jasmine-Matchers/maintainability)\n\n## Table of Contents\n\n-   [Overview](#overview)\n-   [🌩 Installation](#-installation)\n-   [📝 API](#-api)\n-   [🕹 Usage](#-usage)\n-   [🌍 Browser Support](#-browser-support)\n-   [🙋🏽‍♂️ Getting Help](#♂️-getting-help)\n-   [👀 Other Projects](#-other-projects)\n-   [🤓 Author](#-author)\n\n## Overview\n\n##### What\n\nA huge library of test matchers for a range of common use-cases, compatible with all versions of [Jasmine](http://jasmine.github.io/) and [Jest](http://facebook.github.io/jest/).\n\n##### Why\n\nCustom Matchers make tests easier to read and produce relevant and useful messages when they fail.\n\n##### How\n\nBy 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 `expect(cycleWheels).toBeEvenNumber()`.\n\n##### Sponsors\n\n\u003ca href=\"https://browserstack.com\"\u003e\n  \u003cimg alt=\"Sponsored by BrowserStack\" src=\"https://cdn.rawgit.com/JamieMason/Jasmine-Matchers/ad1ea0e6/browserstack.svg\" height=\"40\" /\u003e\n\u003c/a\u003e\n\n## 🌩 Installation\n\n##### npm\n\n    npm install jasmine-expect --save-dev\n\n##### Bower\n\n    bower install jasmine-expect --save-dev\n\n##### Manual\n\nDownloads are available on the [releases](https://github.com/JamieMason/Jasmine-Matchers/releases) page.\n\n## 📝 API\n\nThe [Jasmine testing framework](http://jasmine.github.io/) from [Pivotal Labs](http://pivotallabs.com/) comes with this [default set of matchers](http://jasmine.github.io/edge/introduction.html#section-Expectations):\n\n```js\nexpect().nothing()\nexpect().toBe(expected)\nexpect().toBeCloseTo(expected, precisionopt)\nexpect().toBeDefined()\nexpect().toBeFalse()\nexpect().toBeFalsy()\nexpect().toBeGreaterThan(expected)\nexpect().toBeGreaterThanOrEqual(expected)\nexpect().toBeInstanceOf(expected)\nexpect().toBeLessThan(expected)\nexpect().toBeLessThanOrEqual(expected)\nexpect().toBeNaN()\nexpect().toBeNegativeInfinity()\nexpect().toBeNull()\nexpect().toBePositiveInfinity()\nexpect().toBeTrue()\nexpect().toBeTruthy()\nexpect().toBeUndefined()\nexpect().toContain(expected)\nexpect().toEqual(expected)\nexpect().toHaveBeenCalled()\nexpect().toHaveBeenCalledBefore(expected)\nexpect().toHaveBeenCalledOnceWith()\nexpect().toHaveBeenCalledTimes(expected)\nexpect().toHaveBeenCalledWith()\nexpect().toHaveClass(expected)\nexpect().toHaveSize(expected)\nexpect().toMatch(expected)\nexpect().toThrow(expectedopt)\nexpect().toThrowError(expectedopt, messageopt)\nexpect().toThrowMatching(predicate)\nexpect().withContext(message)\n```\n\nand this [default set of asymmetric matchers](http://jasmine.github.io/2.4/introduction.html#section-Matching_Anything_with_%3Ccode%3Ejasmine.any%3C/code%3E);\n\n```js\njasmine.any(Constructor);\njasmine.anything(mixed);\njasmine.arrayContaining(mixed);\njasmine.objectContaining(mixed);\njasmine.stringMatching(pattern);\n```\n\n### Matchers\n\n[Jasmine-Matchers](https://github.com/JamieMason/Jasmine-Matchers) adds the following matchers:\n\n```js\nexpect(array).toBeArray();\nexpect(array).toBeArrayOfBooleans();\nexpect(array).toBeArrayOfNumbers();\nexpect(array).toBeArrayOfObjects();\nexpect(array).toBeArrayOfSize(number);\nexpect(array).toBeArrayOfStrings();\nexpect(array).toBeEmptyArray();\nexpect(array).toBeNonEmptyArray();\nexpect(boolean).toBeBoolean();\nexpect(date).toBeAfter(otherDate);\nexpect(date).toBeBefore(otherDate);\nexpect(date).toBeDate();\nexpect(date).toBeValidDate();\nexpect(fn).toBeFunction();\nexpect(fn).toThrowAnyError();\nexpect(fn).toThrowErrorOfType(constructorName);\nexpect(mixed).toBeCalculable();\nexpect(number).toBeEvenNumber();\nexpect(number).toBeGreaterThanOrEqualTo(otherNumber);\nexpect(number).toBeLessThanOrEqualTo(otherNumber);\nexpect(number).toBeNear(otherNumber, epsilon);\nexpect(number).toBeNumber();\nexpect(number).toBeOddNumber();\nexpect(number).toBeWholeNumber();\nexpect(number).toBeWithinRange(floor, ceiling);\nexpect(object).toBeEmptyObject();\nexpect(object).toBeNonEmptyObject();\nexpect(object).toBeObject();\nexpect(object).toHaveArray(memberName);\nexpect(object).toHaveArrayOfBooleans(memberName);\nexpect(object).toHaveArrayOfNumbers(memberName);\nexpect(object).toHaveArrayOfObjects(memberName);\nexpect(object).toHaveArrayOfSize(memberName, size);\nexpect(object).toHaveArrayOfStrings(memberName);\nexpect(object).toHaveBoolean(memberName);\nexpect(object).toHaveCalculable(memberName);\nexpect(object).toHaveDate(memberName);\nexpect(object).toHaveDateAfter(memberName, date);\nexpect(object).toHaveDateBefore(memberName, date);\nexpect(object).toHaveEmptyArray(memberName);\nexpect(object).toHaveEmptyObject(memberName);\nexpect(object).toHaveEmptyString(memberName);\nexpect(object).toHaveEvenNumber(memberName);\nexpect(object).toHaveFalse(memberName);\nexpect(object).toHaveHtmlString(memberName);\nexpect(object).toHaveIso8601(memberName);\nexpect(object).toHaveJsonString(memberName);\nexpect(object).toHaveMember(memberName);\nexpect(object).toHaveMethod(memberName);\nexpect(object).toHaveNonEmptyArray(memberName);\nexpect(object).toHaveNonEmptyObject(memberName);\nexpect(object).toHaveNonEmptyString(memberName);\nexpect(object).toHaveNumber(memberName);\nexpect(object).toHaveNumberWithinRange(memberName, floor, ceiling);\nexpect(object).toHaveObject(memberName);\nexpect(object).toHaveOddNumber(memberName);\nexpect(object).toHaveString(memberName);\nexpect(object).toHaveStringLongerThan(memberName, string);\nexpect(object).toHaveStringSameLengthAs(memberName, string);\nexpect(object).toHaveStringShorterThan(memberName, string);\nexpect(object).toHaveTrue(memberName);\nexpect(object).toHaveUndefined(memberName);\nexpect(object).toHaveWhitespaceString(memberName);\nexpect(object).toHaveWholeNumber(memberName);\nexpect(regexp).toBeRegExp();\nexpect(string).toBeEmptyString();\nexpect(string).toBeHtmlString();\nexpect(string).toBeIso8601();\nexpect(string).toBeJsonString();\nexpect(string).toBeLongerThan(otherString);\nexpect(string).toBeNonEmptyString();\nexpect(string).toBeSameLengthAs(otherString);\nexpect(string).toBeShorterThan(otherString);\nexpect(string).toBeString();\nexpect(string).toBeWhitespace();\nexpect(string).toEndWith(substring);\nexpect(string).toStartWith(substring);\n```\n\n### Asymmetric Matchers\n\n```js\nany.after(date);\nany.arrayOfBooleans();\nany.arrayOfNumbers();\nany.arrayOfObjects();\nany.arrayOfSize(number);\nany.arrayOfStrings();\nany.before(date);\nany.calculable();\nany.emptyArray();\nany.emptyObject();\nany.endingWith(string);\nany.evenNumber();\nany.greaterThanOrEqualTo(number);\nany.iso8601();\nany.jsonString();\nany.lessThanOrEqualTo(number);\nany.longerThan(string);\nany.nonEmptyArray();\nany.nonEmptyObject();\nany.nonEmptyString();\nany.oddNumber();\nany.regExp();\nany.sameLengthAs(string);\nany.shorterThan(string);\nany.startingWith(string);\nany.whitespace();\nany.wholeNumber();\nany.withinRange(floor, ceiling);\n```\n\n## 🕹 Usage\n\n### Browser\n\nEmbed [jasmine-matchers.js](https://github.com/JamieMason/Jasmine-Matchers/blob/master/dist/jasmine-matchers.js) after Jasmine but before your tests.\n\n### Jest\n\nInclude the following in your `package.json`:\n\n```json\n\"unmockedModulePathPatterns\": [\"jasmine-expect\"]\n```\n\nAnd the following at the top of your test suite:\n\n```js\nimport JasmineExpect from \"jasmine-expect\";\n```\n\n### Karma\n\nIntegration is easy with the [karma-jasmine-matchers](https://github.com/JamieMason/karma-jasmine-matchers) plugin.\n\n### Node.js\n\nUse the [Jasmine CLI](https://www.npmjs.com/package/jasmine) and include the path to where Jasmine Matchers is installed in the `helpers` array of your `spec/support/jasmine.json`.\n\n```json\n{\n  \"spec_dir\": \"spec\",\n  \"spec_files\": [\"../src/**/*.spec.js\"],\n  \"helpers\": [\"../node_modules/jasmine-expect/index.js\"],\n  \"stopSpecOnExpectationFailure\": false,\n  \"random\": false\n}\n```\n\n### TypeScript and Angular CLI Projects\n\nIf 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.\n\nAlso, if you run into TypeScript compilation errors when running your tests, add `\"jasmine-expect\"` to the `\"types\"` array in your tests' `tsconfig` file.\n\nAs an example, for an Angular CLI based project, this would be your `tsconfig.spec.json` file:\n\n```json\n{\n  \"extends\": \"../tsconfig.json\",\n  \"compilerOptions\": {\n    \"outDir\": \"../out-tsc/spec\",\n    \"baseUrl\": \"./\",\n    \"module\": \"commonjs\",\n    \"target\": \"es5\",\n    \"types\": [\"jasmine\", \"node\", \"jasmine-expect\"]\n  },\n  \"files\": [\"test.ts\"],\n  \"include\": [\"**/*.spec.ts\", \"**/*.d.ts\"]\n}\n```\n\n### Sublime Text\n\n[Jasmine-Matchers-Snippets](https://github.com/JamieMason/Jasmine-Matchers-Snippets) or [Jasmine-Matchers-ES6-Snippets](https://github.com/JamieMason/Jasmine-Matchers-ES6-Snippets) can be installed with [Package Control](https://packagecontrol.io/packages/Jasmine%20Matchers%20Snippets) to ease development with Jasmine Matchers in Sublime Text.\n\n### Tern\n\nThere is a [Plugin](https://github.com/ik9999/tern-jasminematchers) for [Tern](https://github.com/ternjs/tern) to auto-complete matchers in your Text Editor.\n\n## 🌍 Browser Support\n\nJasmine-Matchers is tested on [Travis CI](https://travis-ci.org/JamieMason/Jasmine-Matchers) and [BrowserStack](https://browserstack.com) against the following environments.\n\n| Browser           | Version Range |\n| :---------------- | ------------: |\n| Android           |        9 - 11 |\n| Chrome            |       80 - 85 |\n| Edge              |       80 - 85 |\n| Firefox           |       76 - 80 |\n| iOS               |       10 - 14 |\n| Safari            |       10 - 13 |\n\n## 🙋🏽‍♂️ Getting Help\n\nGet help with issues by creating a [Bug Report] or discuss ideas by opening a [Feature Request].\n\n[bug report]: https://github.com/JamieMason/Jasmine-Matchers/issues/new?template=bug_report.md\n\n[feature request]: https://github.com/JamieMason/Jasmine-Matchers/issues/new?template=feature_request.md\n\n## 👀 Other Projects\n\nIf you find my Open Source projects useful, please share them ❤️\n\n-   [**eslint-formatter-git-log**](https://github.com/JamieMason/eslint-formatter-git-log)\u003cbr\u003eESLint Formatter featuring Git Author, Date, and Hash\n-   [**eslint-plugin-move-files**](https://github.com/JamieMason/eslint-plugin-move-files)\u003cbr\u003eMove and rename files while keeping imports up to date\n-   [**eslint-plugin-prefer-arrow-functions**](https://github.com/JamieMason/eslint-plugin-prefer-arrow-functions)\u003cbr\u003eConvert functions to arrow functions\n-   [**ImageOptim-CLI**](https://github.com/JamieMason/ImageOptim-CLI)\u003cbr\u003eAutomates ImageOptim, ImageAlpha, and JPEGmini for Mac to make batch optimisation of images part of your automated build process.\n-   [**karma-benchmark**](https://github.com/JamieMason/karma-benchmark)\u003cbr\u003eRun Benchmark.js over multiple Browsers, with CI compatible output\n-   [**self-help**](https://github.com/JamieMason/self-help#readme)\u003cbr\u003eInteractive Q\u0026A Guides for Web and the Command Line\n-   [**syncpack**](https://github.com/JamieMason/syncpack#readme)\u003cbr\u003eManage multiple package.json files, such as in Lerna Monorepos and Yarn Workspaces\n\n## 🤓 Author\n\n\u003cimg src=\"https://www.gravatar.com/avatar/acdf106ce071806278438d8c354adec8?s=100\" align=\"left\"\u003e\n\nI'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.\n\n\u003cdiv align=\"center\"\u003e\n\n[![Follow JamieMason on GitHub][github badge]][github]      [![Follow fold_left on Twitter][twitter badge]][twitter]\n\n\u003c/div\u003e\n\n\u003c!-- images --\u003e\n\n[github badge]: https://img.shields.io/github/followers/JamieMason.svg?style=social\u0026label=Follow\n\n[twitter badge]: https://img.shields.io/twitter/follow/fold_left.svg?style=social\u0026label=Follow\n\n\u003c!-- links --\u003e\n\n[arsenal]: https://www.arsenal.com\n\n[betfair]: https://www.betfair.com\n\n[github]: https://github.com/JamieMason\n\n[jamie mason]: https://www.linkedin.com/in/jamiemasonleeds\n\n[leeds united]: https://www.leedsunited.com/\n\n[leeds]: https://www.instagram.com/visitleeds\n\n[premier league]: https://www.premierleague.com\n\n[shell]: https://www.shell.com\n\n[sky bet]: https://www.skybet.com\n\n[sky poker]: https://www.skypoker.com\n\n[sky sports]: https://www.skysports.com\n\n[spurs]: https://www.tottenhamhotspur.com\n\n[twitter]: https://twitter.com/fold_left\n\n[west ham]: https://www.whufc.com\n\n[william hill]: https://www.williamhill.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJamieMason%2FJasmine-Matchers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJamieMason%2FJasmine-Matchers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJamieMason%2FJasmine-Matchers/lists"}