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/exists

exists()

Method that check if element are render by the component.

Example

React

const MyComponent = () => (<div id="exist">hello world</div>);

const cmp = shallow(<MyComponent/>);


expect(cmp.querySelector('#exist').exists()).toBe(true);
expect(cmp.querySelector('#notExist').exists()).toBe(false);
← shallow/querySelectorsshallow/dispatchEvent →
  • exists()
    • Example
Component test utils
Docs
Getting StartedAPI Reference
More
BlogGitHubStar
MIT Copyright © 2020 Florent Berthelot