{"id":17987795,"url":"https://github.com/dirkluijk/observable-matchers","last_synced_at":"2026-03-12T16:03:34.487Z","repository":{"id":44089474,"uuid":"200943564","full_name":"dirkluijk/observable-matchers","owner":"dirkluijk","description":"RxJS Observable Matchers for Jest and Jasmine","archived":false,"fork":false,"pushed_at":"2022-02-12T11:28:07.000Z","size":286,"stargazers_count":6,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T13:36:45.666Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirkluijk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-07T00:37:35.000Z","updated_at":"2022-08-14T11:13:16.000Z","dependencies_parsed_at":"2022-09-03T13:21:34.305Z","dependency_job_id":null,"html_url":"https://github.com/dirkluijk/observable-matchers","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dirkluijk/observable-matchers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkluijk%2Fobservable-matchers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkluijk%2Fobservable-matchers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkluijk%2Fobservable-matchers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkluijk%2Fobservable-matchers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirkluijk","download_url":"https://codeload.github.com/dirkluijk/observable-matchers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirkluijk%2Fobservable-matchers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30431565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T14:34:45.044Z","status":"ssl_error","status_checked_at":"2026-03-12T14:09:33.793Z","response_time":114,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-10-29T19:09:40.311Z","updated_at":"2026-03-12T16:03:34.466Z","avatar_url":"https://github.com/dirkluijk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxJS Observable Matchers\n\n\u003e Custom RxJS Observable matchers for Jest and Jasmine\n\n[![NPM version](http://img.shields.io/npm/v/@dirkluijk/observable-matchers.svg?style=flat-square)](https://www.npmjs.com/package/@dirkluijk/observable-matchers)\n[![NPM downloads](http://img.shields.io/npm/dm/@dirkluijk/observable-matchers.svg?style=flat-square)](https://www.npmjs.com/package/@dirkluijk/observable-matchers)\n[![Build status](https://img.shields.io/travis/dirkluijk/observable-matchers.svg?style=flat-square)](https://travis-ci.org/dirkluijk/observable-matchers)\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)\n\n## Overview\n\n### What\n\nA small set of test matchers for testing RxJS Observables, compatible with\nall versions of [Jasmine](http://jasmine.github.io/) and\n[Jest](http://facebook.github.io/jest/).\n\n### Why\n\nWhen testing simple RxJS observables, [RxJS Marble Testing]() may be too verbose.\nThis set of test matchers may provide a more simple API and reduce boilerplate code. \n\n### Limitations\n\nThe matchers provided in this package only support synchronous streams.\n\n**Testing asynchronous Observables is not (yet) supported!**\n\n## Installation 🌩\n\n##### npm\n\n```\nnpm install @dirkluijk/observable-matchers --save-dev\n```\n\n##### yarn\n\n```\nyarn add @dirkluijk/observable-matchers --dev\n```\n\n## API 📝\n\n### Asymmetric Matchers (recommended)\n\n```typescript\nimport { of } from 'rxjs';\nimport {\n    next,\n    completed,\n    emptyObservable,\n    completedObservable,\n    failedObservable,\n    observable,\n    observableWithSize\n} from '@dirkluijk/observable-matchers';\n\nconst completed$ = of(10, 20, 30);\n\nexpect(completed$).toEqual(observable(\n    next(10),\n    next(20),\n    next(30),\n    completed()\n));\nexpect(completed$).not.toEqual(emptyObservable());\nexpect(completed$).toEqual(completedObservable());\nexpect(completed$).not.toEqual(failedObservable());\nexpect(completed$).toEqual(observableWithSize(3));\n```\n\n### Matchers\n\n```typescript\nimport { of } from 'rxjs';\nimport { next, completed } from '@dirkluijk/observable-matchers';\nimport '@dirkluijk/observable-matchers/matchers';\n\nconst completed$ = of(10, 20, 30);\n\nexpect(completed$).toBeObservable([\n    next(10),\n    next(20),\n    next(30),\n    completed()\n]);\nexpect(completed$).not.toBeEmpty();\nexpect(completed$).toBeCompleted();\nexpect(completed$).not.toBeFailed();\nexpect(completed$).toBeOfSize(3);\n```\n\n### Record utility\n\nSometimes a stream does not replay its events. In order to capture its events,\nyou can use the provided `record()` function. \n\n```typescript\nimport { record, emptyObservable } from '@dirkluijk/observable-matchers';\nimport '@dirkluijk/observable-matchers/matchers';\n\nconst recorded$ = record(someStream());\n\ntriggerEvents();\n\nexpect(recorded$).not.toEqual(emptyObservable());\n// or \nexpect(recorded$).not.toBeEmpty();\n```\n\n## Usage 🕹\n\nIn order to use the asymmetric matchers (e.g. `toEqual(observable(...))`, `toEqual(completedObservable())`),\nyou just need to import them as pure functions:\n\n```js\nimport { completedObservable, observable } from '@dirkluijk/observable-matchers';\n```\n\nIn order to use the matchers (e.g. `toBeObservable`, `toBeCompleted`), you need\nto register the matchers and import the typings as follows:\n\n```js\nimport '@dirkluijk/observable-matchers/matchers';\n```\n\n**Please note that the use of matchers may collide with matchers from other libraries.**\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/dirkluijk\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/2102973?v=4\" width=\"100px;\" alt=\"Dirk Luijk\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDirk Luijk\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/dirkluijk/@dirkluijk/observable-matchers/commits?author=dirkluijk\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/dirkluijk/@dirkluijk/observable-matchers/commits?author=dirkluijk\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://craftsmen.nl/\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/16564855?v=4\" width=\"100px;\" alt=\"Daan Scheerens\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDaan Scheerens\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-dscheerens\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirkluijk%2Fobservable-matchers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirkluijk%2Fobservable-matchers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirkluijk%2Fobservable-matchers/lists"}