Skip to content

A custom matcher to be extended by Jest, to allow you to check existence of enzyme selectors

Notifications You must be signed in to change notification settings

cgood92/jest-enzyme-selector-exists

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jest-enzyme-selector-exists

A custom matcher to be extended by Jest, to allow you to check existence of enzyme selectors

To use

This package means nothing without having the depenedencies enzyme and jest.

Install this package

npm install jest-enzyme-selector-exists

Implement

If you have a jest-setup.js file, I suggest putting the following code in there.

If not, you can add the following code to the test file from which you are doing your assertions:

import toExist from "./index"

expect.extend(toExist)

Assert

const wrapper = shallow(<YourComponent />)

// h1 should exist
expect(wrapper.find('h1')).toExist()

// h2 should not exist
expect(wrapper.find('h2')).toExist(false)
expect(wrapper.find('h2')).not.toExist()

About

A custom matcher to be extended by Jest, to allow you to check existence of enzyme selectors

Resources

Stars

Watchers

Forks

Packages

No packages published