FormidableLabs/react-native-svg-mock

Name: react-native-svg-mock

Owner: Formidable

Description: A mock implementation of react-native-svg for use in tests

Created: 2016-08-10 20:13:51.0

Updated: 2017-12-15 01:31:23.0

Pushed: 2017-11-10 01:12:37.0

Homepage:

Size: 68

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status npm version

react-native-svg-mock

A mock implementation of react-native-svg for use in tests. Inspired by react-native-mock.

Install

With npm, do:

install react-native-svg-mock --save-dev
Usage
ile-that-runs-before-all-of-my-tests.js */

his will mutate `react-native-svg`'s require cache with `react-native-svg-mock`'s.
ire('react-native-svg-mock/mock'); // <-- side-effects!!!

Or, with something like Mockery, do:

rt mockery from "mockery";
rt reactNativeSvgMock from "react-native-svg-mock";

ery.enable();
ery.registerMock("react-native-svg", reactNativeSvgMock);

In a test with Enzyme and Mocha, this could look like:

rt "react-native-mock/mock";
rt "react-native-svg-mock/mock";

rt { render } from "enzyme";
rt { expect } from "chai";

rt { VictoryChart } from "victory-native";

ribe("<VictoryChart />", function () {
("should render", function () {
var component = render(<VictoryChart />);
expect(component).to.have.length(1);
;


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.