@scott-m-sarsfield/spy-on-render
stub react render in jasmine
Last updated a year ago by scott.m.sarsfield .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @scott-m-sarsfield/spy-on-render 
SYNC missed versions from official npm registry.

@scott-m-sarsfield/spy-on-render

Spy on React components in Jasmine tests.

DOES NOT WORK WITH FUNCTIONAL COMPONENTS. They're functions!

HOWEVER, I'VE ADDED SOME USEFUL ERROR MESSAGES.

Installation

npm install spy-on-render

Put this in your spec_helper.js:

require('spy-on-render');

Usage

spyOnRender

Just call it:

spyOnRender(Component);

By default, it won't render anything. If you want to render normally:

spyOnRender(Component).and.callThrough();

spyOnRender returns a spy, so you can do whatever you want with it.

Matchers

was the component rendered?

expect(Component).toHaveBeenRendered();

with specific properties?

expect(Component).toHaveBeenRenderedWithProps({
  className: 'whatever',
  otherProp: 'whocares'
});

Helpers

what props were rendered last?

propsOnLastRender(Component)

what props were rendered at some other point in time?

propsOnRenderAt(Component, i)

Contributing

If you need to publish the package,

gulp build
cd dist
npm publish

(don't forget to increment the version)

Current Tags

  • 0.2.3                                ...           latest (a year ago)

3 Versions

  • 0.2.3                                ...           a year ago
  • 0.2.2                                ...           a year ago
  • 0.2.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |