パッケージの詳細

react-native-svg-mock

FormidableLabs11.2kMIT2.0.0

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

react, react-native, react-native-svg, mock

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:

npm install react-native-svg-mock --save-dev

Usage

/* file-that-runs-before-all-of-my-tests.js */

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

Or, with something like Mockery, do:

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

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

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

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

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

import { VictoryChart } from "victory-native";

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

更新履歴

react-native-svg-mock changelog

2.0.0 (2017-11-09)

Update dependencies and test infrastructure for React 16 and React Native 0.50.0 compat

1.1.0 (2017-06-15)

Add TSpan and TextPath mocks. Update react-* dependencies.

1.0.2 (2016-08-10)

Fix automock path

1.0.1 (2016-08-10)

Fix default export

1.0.0 (2016-08-10)

Initial release