Component test utils

Component test utils

  • Philosophy
  • Doc
  • Blog

›Shallow

Introduction

  • Documentation
  • Getting Started

Shallow

  • shallow/constructor
  • shallow/html
  • shallow/props
  • shallow/setProps
  • shallow/querySelector
  • shallow/querySelectors
  • shallow/exists
  • shallow/dispatchEvent
  • shallow/unmount

Frameworks

  • api-react
  • api-vuejs
  • api-angular
  • api-vanilla

shallow/unmount

unmount()

Unmount a component. After unmounting a component shallow method will throw error.

Example

React

const orderTester = [];
class Component extends React.Component {
  render() {
    orderTester.push('render');
    return <div />;
  }

  componentWillUnmount() {
    orderTester.push('componentWillUnmount');
  }
}

const cmp = shallow(<Component />);

cmp.unmount();

expect(orderTester).toEqual(['render', 'componentWillUnmount']);
← shallow/dispatchEventapi-react →
  • unmount()
    • Example
Component test utils
Docs
Getting StartedAPI Reference
More
BlogGitHubStar
MIT Copyright © 2020 Florent Berthelot