New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

enzyme-to-json-mock-props

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enzyme-to-json-mock-props

it gives you the ability to mock props generated via enzyme-to-json

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

enzyme-to-json-mock-props npm Build Status Coverage Status

it gives you the ability to mock props generated via enzyme-to-json.

Install

npm install enzyme-to-json-mock-props

Example

Assuming you are using enzyme-to-json/serializer as snapshotSerializers, example.

import * as React from "react";
import { shallow } from "enzyme";
import mockProps from "enzyme-to-json-mock-props";

const SubComponent = () => <div />;

const Component = props => (
  <SubComponent {...props} style={{ background: "red", color: "black" }} />
);

describe("my snapshot", () => {
  const props = {
    foo: {
      bar: 123
    },
    foobar: "asd",
    asd: {
      qwe: 321
    }
  };
  it("should render properly", () => {
    const wrapper = shallow(<Component {...props} />);
    expect(
      mockProps(wrapper, ["foo", "foobar", "style", "qwe"])
    ).toMatchSnapshot();
  });
});

before (without mockProps):

exports[`enzyme-to-json-mock-props should render properly 1`] = `
<SubComponent
  asd={
    Object {
      "qwe": 321,
    }
  }
  foo={
    Object {
      "bar": 123,
    }
  }
  foobar="asd"
  style={
    Object {
      "background": "red",
      "color": "black",
    }
  }
/>
`;

after (with mockProps):

exports[`enzyme-to-json-mock-props should mock the indicated props 1`] = `
<SubComponent
  asd={
    Object {
      "qwe": 321,
    }
  }
  foo="[foo]"
  foobar="[foobar]"
  style="[style]"
/>
`;

Keywords

FAQs

Package last updated on 10 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc