Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 10:09
    tonnyskk commented #2518
  • 10:09
    tonnyskk commented #2518
  • May 20 22:57
    ljharb commented #2518
  • May 20 22:18
    nspector commented #2518
  • May 20 20:05
    ljharb commented #2518
  • May 20 18:37
    rxgx commented #2518
  • May 20 18:35
    rxgx commented #2518
  • May 20 18:20
    ljharb commented #2518
  • May 20 18:05
    rxgx commented #2518
  • May 20 18:01
    rxgx commented #2518
  • May 20 17:34
    ljharb commented #2518
  • May 20 17:33
    ljharb commented #2518
  • May 20 17:33
    ljharb commented #2518
  • May 20 17:32
    rxgx commented #2518
  • May 20 17:28
    ljharb commented #2518
  • May 20 17:28
    rxgx commented #2518
  • May 20 17:27
    rxgx commented #2518
  • May 20 17:00
    ljharb closed #2558
  • May 20 17:00
    ljharb commented #2558
  • May 20 16:38
    ryanrd opened #2558
Tomek Kasperek
Okay. Cool. So for now there is no resolution for this right, other than downgrading to earlier versions
Does anyone have a clue about this issue, enzymejs/enzyme#2415
Hardik Kaji
Hello 👋 , I am facing issue with mount with MobX observer component.
it's throwing below error.
 ✖ should render properly
      HeadlessChrome 83.0.4103 (Mac OS X 10.15.6)
    Error: Enzyme Internal Error: unknown node with tag 15

describe("<SomeComponent />", function () {
    it("should render properly", function () {
        const component = mount(
                <SomeComponent />
The error comes when i wrap my component with observer(SomeComponent)
Hello, I am facing issue with the shallow
const props = {
intl: { formatMessage: jest.fn() },
resetFormAction: jest.fn(),
history: jest.fn()
let instance = null;

beforeEach(() => {
    instance = shallow(<NotificationView {...props}/>);

it('should render the notification component', () => {

it('should find the elements of the notification component', () => {

    const notification = instance.find(Notification);
    const notificationActionBar = instance.find(NotificationActionBar);

TypeError: Enzyme::Selector expects a string, object, or Component Constructor
Jordan Harband
the implication is that either Notification or NotificationActionBar is not actually a component constructor.
try console.logging them and confirm

Hi, I am new to enzyme.
I am trying to test my functional component, but shallow returns me always null. Any idea where I should look at?

const wrapper = shallow(<MyComponent />);

I do have set adapter in setupTest.js (app created with create-react-app)

import '@testing-library/jest-dom/extend-expect';
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";

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

I have tried to shallow on direct html element and this works fine.

const wrapper = shallow(<div >test</div>);

For check I use

2 replies
Abhishek Singh
Hi I am stuck with something, can anyone help me out?
I am calling a member function of a class component using enzyme in a unit test, and that function calls thethis.setState
but the state of my component is not updating
Abhishek Singh
class MyComp extends React.Component {
    state = { value: '' }
    handleChange = (e) => {
        this.setState({ value: e.target.value }, () => {
            // do sommething else

    render() {
        return (
            <input onChange={ this.handleChange } />

const wrapper = shallow(<MyComp />);

wrapper.find('input').simulate('change', {
    target: {
        value: 1,
        name: 0

expect(wrapper.state().value).toEqual('1'); // this gives error as it is receiving state.value as ''
6 replies
Can anyone please help me understand why the component's internal setState is not working?
Jordan Harband
oh, well yeah
this.setState shouldn't be given an object, it should be given a callback
altho hm
that should work. but since you do handleChange =, instead of a proper bound prototype method, that means you also can't mock it out
(don't put functions in class fields)
Hi everyone, I'm new to web development and I've started using enzyme a few days ago.
I am using mount to load a component into the DOM. One of its children is a Blueprint3.Select component whose value I want to change.
Unlike with shallow, I cannot use simulate on the react component to change its value which is wrapped in a <div>.
I have two questions:
  • Is there a way I can manipulate the DOM directly to set the value of the <div> of this component?
  • Can we use simulate on React component when using mount?
Jordan Harband
i wouldn't suggest using simulate ever
if you want to invoke a prop function, use .invoke
@ljharb Thanks :)
Nick Artemov
hi all
do you know right way to test FunctionalComponent with useEffect/useCallback ?
Ashik Meerankutty
hi everyone is there a way to use setSelectionRange for a textarea
Jenifer L.
Hi, Is anybody here?
I have a component wrapper with a Provider and store and I simulate a click event. I want to test that some state prop has change but nothing changes
hello, one question, is there already an adapter for react 17?
Jordan Harband
no, not yet. There’s an open issue to track it.
Hi, I am having an issue with getting enzyme to work in our react 16 app:
Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none.
Is there anyone who could get in touch with me, we seem to have exhausted all the references and SO related links and we just can not get it to work. Please :(
Jordan Harband
the docs describe configuring an adapter, have you done that?
We tried, sorry for the late response.
We ended up abandoning Enzyme.
We were working in TS and just couldn't make it work.
Maybe you guys should reevaluate the docs because there are quite a few instances of people just not being able to get it to work.
Jordan Harband
lol, after 4 hours?
i'm happy to improve the doc, but afaik using TS doesn't change anything, and https://enzymejs.github.io/enzyme/docs/installation/ covers configuring the adapter
Hello everyone. I'm new in Gitter. Hope to learn with the community and share knowlegde. if someone like to guide me through, i'm an I am an open-minded. Thanks in advance for your welcome
I have a hard time testing lazy loading component using React.Suspense and React.lazy. I'm using "enzyme": "^3.10.3",. I'm wondering if that is supported or how would I test it ?
Jordan Harband
it should be supported, using the suspenseFallback option. try enzyme v3.11, and the latest adapter, just in case.

Hey there. I'm facing an interesting problem that I can't figure out:
I got a form which I'm testing, so I get the submit button like this: button = wrapper.find('#notification-channel-add-button')
I then try so simulate a change event: input.simulate('change', { target: { value: 'Sample text' } })
Then, depending on how I test the disabled state of the button, I get different results:

// Correctly passes

// This fails

Has anyone ever faced this problem?

I have published my article on React check out . Give a clap and Share. Open for feedback
Rostislav Radionov
1 reply
Hello everyone!
Can anyone come across such a problem?
The component is static and don't have asynchronous logic
Jordan Harband
@radionov018 sorry, missed this here. enzyme doesn't support react 17 yet.
Rodo Abad
Damn, Jordan, you're always online. LOL.
Jordan Harband
lol true