What is should-enzyme: An library of extension functions for ShouldJS and a wrapper round Enzyme.

Why use it: Make it easier to test ReactJS components, improve readability of asserts and provide better error messaging on failing tests.

Should-Enzyme API in the read me on Github and is an NPM package.


You need EnzymeJS and ShouldJS installed to use Should Enzyme.

Install: npm i should-enzyme --save-dev

import "should";
import "should-enzyme";

Here is an example extension function to test if a CSS class is in the className string value.


render mount shallow
yes yes yes

Check to see if wrapper has CSS class.

import React from "react";
import { mount, render, shallow } from "enzyme";

const ClassNameFixture = () => (
  <div className="special burger">Content here</div>

const wrapper = mount(<ClassNameFixture />);