https://github.com/ksm2/jest-stream-marbles
Jest extension to test WHATWG Streams with marble syntax
https://github.com/ksm2/jest-stream-marbles
jest marble-testing streams-api whatwg-streams
Last synced: 12 months ago
JSON representation
Jest extension to test WHATWG Streams with marble syntax
- Host: GitHub
- URL: https://github.com/ksm2/jest-stream-marbles
- Owner: ksm2
- License: mit
- Created: 2021-11-27T18:06:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-28T13:34:04.000Z (over 4 years ago)
- Last Synced: 2025-02-22T01:34:50.874Z (about 1 year ago)
- Topics: jest, marble-testing, streams-api, whatwg-streams
- Language: TypeScript
- Homepage:
- Size: 249 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# jest-stream-marbles
[](https://github.com/ksm2/jest-stream-marbles/actions/workflows/node.js.yml)
[](https://www.npmjs.com/package/jest-stream-marbles)
[](https://opensource.org/licenses/MIT)

> Jest extension to test [WHATWG Streams] with [Marble Syntax]
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Contributing](#contributing)
- [See Also](#see-also)
- [License](#license)
## Install
Use either
yarn add jest-stream-marbles
or
npm install jest-stream-marbles
## Usage
This module allows you to test [WHATWG Streams] with [Marble Syntax] in Jest.
```js
import { marbles } from "jest-stream-marbles";
import { filter } from "stream-transformers";
describe("filter", () => {
it("should filter a stream by a predicate", async () => {
const act = marbles`---${1}-${2}--${3}-${4}---|`;
const exp = marbles`--------${2}-------${4}---|`;
await expect(act.pipeThrough(filter(isEven))).toStream(exp);
});
it("should fail the other stream", async () => {
const act = marbles`---${1}-${2}--x`;
const exp = marbles`--------${2}--x`;
await expect(act.pipeThrough(filter(isEven))).toStream(exp);
});
});
function isEven(num: number): boolean {
return num % 2 === 0;
}
```
## Contributing
This project is open to feedback and contributions, [please open an issue](https://github.com/ksm2/jest-stream-marbles/issues).
`jest-stream-marbles` follows the [Contributor Covenant] Code of Conduct.
## See Also
Also have a look at the following NPM Packages:
- [isomorphic-streams](https://github.com/ksm2/isomorphic-streams) - Isomorphic package for WHATWG Streams in Node.js and the browser.
- [stream-transformers](https://github.com/ksm2/stream-transformers) - Reusable stream transformers similar to ReactiveX Operators.
## License
MIT © 2021 Konstantin Möllers, see [LICENSE].
[whatwg streams]: https://streams.spec.whatwg.org/
[marble syntax]: https://rxjs.dev/guide/testing/marble-testing
[license]: https://github.com/ksm2/jest-stream-marbles/blob/main/LICENSE
[contributor covenant]: https://github.com/ksm2/jest-stream-marbles/blob/main/CODE_OF_CONDUCT.md