3.1.1 • Published 5 years ago

marble-test v3.1.1

Weekly downloads
82
License
MIT
Repository
github
Last release
5 years ago

Helps you write marble tests

Install

$ npm install --save-dev marble-test

Example usage

import { createRxTestScheduler } from 'marble-test'

const mapToNumber$ = string$ => string$.pipe(map(s => Number(s)))

test('map to number', () => {
  // Arrange
  const scheduler = createRxTestScheduler()
  const values = { a: '1', b: '2', 1: 1, 2: 2 }
  const input = 'a--b|'
  const output = '1--2|'
  const strings$ = scheduler.createColdObservable(input, values)

  // Act
  const obs = mapToNumber$(strings$)

  // Assert
  scheduler.expectObservable(obs).toBe(output, values)
  scheduler.flush()
})

With jest

import { marble } from 'marble-test/jest'

const mapToNumber$ = string$ => string$.pipe(map(s => Number(s)))

marble('map to number', m => {
  // Arrange
  const values = { a: '1', b: '2', 1: 1, 2: 2 }
  const input = 'a--b|'
  const output = '1--2|'
  const strings$ = m.cold(input, values)

  // Act
  const obs = mapToNumber$(strings$)

  // Assert
  m.expectObservable(obs).toBe(output, values)
})

See the test file for more examples

Gives detailed outputs on assert failure. e.g., You will get the following output when changing output above to a--2|

npm.io

API

createRxTestScheduler()

Returns a TestScheduler (https://github.com/ReactiveX/rxjs/blob/master/src/testing/TestScheduler.ts)

See https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md for more info

3.1.1

5 years ago

3.0.0

6 years ago

2.3.0

7 years ago

2.2.3

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago