{"library":"rx-sandbox","title":"RxSandbox: RxJS Marble Diagram Test Suite","description":"RxSandbox is a dedicated testing utility for RxJS Observables, employing a Domain Specific Language (DSL) based on marble diagrams to simplify assertions over virtual time. The current stable version, 2.0.5, is designed specifically for RxJS 7.0.1 and newer, while earlier major versions (1.x) supported RxJS 6.x, and pre-1.x versions accommodated RxJS 5. The project is actively maintained, though its development cadence is primarily tied to upstream RxJS releases rather than continuous feature additions, as it's considered feature-complete. It differentiates itself from the core RxJS `TestScheduler` by offering an extended marble diagram DSL, requiring near-zero configuration, operating independently of specific test frameworks, and supporting flexible `TestMessage` creation for granular testing scenarios.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install rx-sandbox"],"cli":null},"imports":["import { createSandbox } from 'rx-sandbox';","import type { RxSandboxInstance } from 'rx-sandbox';","const { get, cold, hot, expectObservable, expectSubscriptions } = createSandbox();"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createSandbox } from 'rx-sandbox';\nimport { map, take } from 'rxjs/operators';\n\nfunction runRxSandboxTest() {\n  // Initialize the sandbox, destructuring common utilities for convenience.\n  const { get, cold, hot, expectObservable, expectSubscriptions } = createSandbox();\n\n  // Example 1: Testing a cold observable transformation\n  // 'cold' creates an observable that starts emitting when subscribed.\n  const source$ = cold('-a-b-c|', { a: 1, b: 2, c: 3 });\n  const mapped$ = source$.pipe(map(x => x * 10));\n  // 'expectObservable' asserts the output using marble syntax and a value map.\n  expectObservable(mapped$).toBe('-A-B-C|', { A: 10, B: 20, C: 30 });\n\n  // Example 2: Testing a hot observable with subscription points and unsubscription\n  // 'hot' creates an observable that is already active when subscribed.\n  const hotSource$ = hot('--a--b--c--d|');\n  // 'sub' defines the subscription (^) and unsubscription (!) frames.\n  const sub =           '^----------!'; // Subscribes at frame 0, unsubscribes at frame 10\n  const result$ = hotSource$.pipe(take(3), map(x => x.toUpperCase()));\n  // Assert the observable's output and verify its subscription behavior.\n  expectObservable(result$, sub).toBe('--A--B--C|', { A: 'A', B: 'B', C: 'C' });\n  expectSubscriptions(hotSource$.subscriptions).toBe(sub);\n\n  console.log('RxSandbox tests are defined. In a real test runner (e.g., Jest, Mocha),');\n  console.log('these assertions would automatically execute and report outcomes.');\n}\n\n// Execute the test function. In a typical test suite, this would be within `it()` blocks.\nrunRxSandboxTest();","lang":"typescript","description":"Demonstrates initializing `rx-sandbox` and using its `cold`, `hot`, `expectObservable`, and `expectSubscriptions` methods with marble diagrams to test RxJS operators and observable lifecycles.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}