1.1.0 β€’ Published 4 years ago

enzyme-dive v1.1.0

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

πŸŠπŸΌβ€β™‚ Dive deep️

Installation

1. Add Package

yarn add enzyme-dive --dev

2. Extend Enzyme in your setup file

import * as Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-xx';
import configure from "enzyme-dive";

Enzyme.configure({ adapter: new Adapter() });

// The magic πŸ§™πŸΌβ€β™‚οΈ
configure(Enzyme.ShallowWrapper);

Usage

diveTo(selector)

Use this to dive until you reach your component. This can be useful if you've got many HoC wrappers.

import React from 'react';
import { shallow } from "enzyme";
import Component from './Component';
import ChildComponent from './ChildComponent';

describe('<Component />', function() {
  it("should render child", () => {
      const wrapper = shallow(<Component />).diveTo(ChildComponent);

      expect(wrapper).toMatchSnapshot();
  });
});

diveDeep(depth)

Dive through your nodes a specified amount

import React from 'react';
import { shallow } from "enzyme";
import Component from './Component';

describe('<Component />', function() {
  it("should render", () => {
      // const wrapper = shallow(<Component />).dive().dive().dive().dive().dive();
      const wrapper = shallow(<Component />).diveDeep(5);

      expect(wrapper).toMatchSnapshot();
  });
});
1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago