Gathering detailed insights and metrics for @miller-svt/jest-marbles
Gathering detailed insights and metrics for @miller-svt/jest-marbles
Gathering detailed insights and metrics for @miller-svt/jest-marbles
Gathering detailed insights and metrics for @miller-svt/jest-marbles
Helpers library for marbles testing with Jest
npm install @miller-svt/jest-marbles
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (86.09%)
JavaScript (13.32%)
Shell (0.59%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
113 Stars
552 Commits
13 Forks
4 Watchers
91 Branches
9 Contributors
Updated on May 20, 2025
Latest Version
3.1.0
Package Id
@miller-svt/jest-marbles@3.1.0
Unpacked Size
233.60 kB
Size
38.39 kB
File Count
85
NPM Version
10.5.0
Node Version
20.12.2
Published on
May 31, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
27
A set of helper functions and Jest matchers for RxJs marble testing. This library will help you to test your reactive code in easy and clear way.
For RxJs 7:
1npm i jest-marbles@latest -D
For RxJs 6:
1npm i jest-marbles@2 -D
For RxJs 5:
1npm i jest-marbles@1 -D
In the test file:
1import {cold, hot, time, schedule} from 'jest-marbles';
Inside the test:
1expect(stream).toBeObservable(expected); 2expect(stream).toBeMarble(marbleString); 3expect(stream).toHaveSubscriptions(marbleString); 4expect(stream).toHaveSubscriptions(marbleStringsArray); 5expect(stream).toHaveNoSubscriptions(); 6expect(stream).toSatisfyOnFlush(() => { 7 expect(someMock).toHaveBeenCalled(); 8})
Verifies that the resulting stream emits certain values at certain time frames
1 it('Should merge two hot observables and start emitting from the subscription point', () => { 2 const e1 = hot('----a--^--b-------c--|', {a: 0}); 3 const e2 = hot(' ---d-^--e---------f-----|', {a: 0}); 4 const expected = cold('---(be)----c-f-----|', {a: 0}); 5 6 expect(e1.pipe(merge(e2))).toBeObservable(expected); 7 });
Sample output when the test fails (if change the expected result to '-d--(be)----c-f-----|'
):
Expected notifications to be:
"-d--(be)----c-f-----|"
But got:
"---(be)----c-f-----|"
Same as toBeObservable
but receives marble string instead
1 it('Should concatenate two cold observables into single cold observable', () => { 2 const a = cold('-a-|'); 3 const b = cold('-b-|'); 4 const expected = '-a--b-|'; 5 expect(a.pipe(concat(b))).toBeMarble(expected); 6 });
Verifies that the observable was subscribed in the provided time frames.
Useful, for example, when you want to verify that particular switchMap
worked as expected:
1 it('Should figure out single subscription points', () => { 2 const x = cold(' --a---b---c--|'); 3 const xsubs = ' ------^-------!'; 4 const y = cold(' ---d--e---f---|'); 5 const ysubs = ' --------------^-------------!'; 6 const e1 = hot(' ------x-------y------|', { x, y }); 7 const expected = cold('--------a---b----d--e---f---|'); 8 9 expect(e1.pipe(switchAll())).toBeObservable(expected); 10 expect(x).toHaveSubscriptions(xsubs); 11 expect(y).toHaveSubscriptions(ysubs); 12 });
The matcher can also accept multiple subscription marbles:
1 it('Should figure out multiple subscription points', () => { 2 const x = cold(' --a---b---c--|'); 3 4 const y = cold(' ----x---x|', {x}); 5 const ySubscription1 = ' ----^---!'; 6 // '--a---b---c--|' 7 const ySubscription2 = ' --------^------------!'; 8 const expectedY = cold(' ------a---a---b---c--|'); 9 10 const z = cold(' -x|', {x}); 11 // '--a---b---c--|' 12 const zSubscription = ' -^------------!'; 13 const expectedZ = cold(' ---a---b---c--|'); 14 15 expect(y.pipe(switchAll())).toBeObservable(expectedY); 16 expect(z.pipe(switchAll())).toBeObservable(expectedZ); 17 18 expect(x).toHaveSubscriptions([ySubscription1, ySubscription2, zSubscription]); 19 });
Sample output when the test fails (if change ySubscription1
to '-----------------^---!'
):
Expected observable to have the following subscription points:
["-----------------^---!", "--------^------------!", "-^------------!"]
But got:
["-^------------!", "----^---!", "--------^------------!"]
Verifies that the observable was not subscribed during the test. Especially useful when you want to verify that certain chain was not called due to an error:
1 it('Should verify that switchMap was not performed due to an error', () => { 2 const x = cold('--a---b---c--|'); 3 const y = cold('---#-x--', {x}); 4 const result = y.pipe(switchAll()); 5 expect(result).toBeMarble('---#'); 6 expect(x).toHaveNoSubscriptions(); 7 });
Sample output when the test fails (if remove error and change the expected marble to '------a---b---c--|'
):
Expected observable to have no subscription points
But got:
["----^------------!"]
Allows you to assert on certain side effects/conditions that should be satisfied when the observable has been flushed (finished)
1 it('should verify mock has been called', () => { 2 const mock = jest.fn(); 3 const stream$ = cold('blah|').pipe(tap(mock)); 4 expect(stream$).toSatisfyOnFlush(() => { 5 expect(mock).toHaveBeenCalledTimes(4); 6 }); 7 })
Allows you to schedule task on specified frame
1 it('should verify subject values', () => { 2 const source = new Subject(); 3 const expected = cold('ab'); 4 5 schedule(() => source.next('a'), 1); 6 schedule(() => source.next('b'), 2); 7 8 expect(source).toBeObservable(expected); 9 });
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/2 approved changesets -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More