question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: This method is only meant to be run on single node. 0 found instead.

See original GitHub issue

Clearly rendering a node. It’s not picking it up…?

render() {
    let groceriesComponents = [],
        newProductInput,
        newProductAddButton,
        clearListButton;

    for(var index = 0; index < this.state.groceries.length; index++) {
      groceriesComponents.push(
          <GroceryListItem
            key={index}
            grocery={this.state.groceries[index]}
          />
      );
    }

    newProductInput = <input className='new-item' type="text" onChange={this.inputChanged}/>;
    newProductAddButton = <button className='add-product' onClick={this.addGroceryItem}>Add new Product</button>;
    clearListButton = <button onClick={this.clearList} className='clear-list'>Clear the List</button>;

    return (
      <div>
        <ul>
          {groceriesComponents}
        </ul>
        {newProductInput}
        {newProductAddButton}
        {clearListButton}
      </div>
    );
  }
}
describe("Task #3 - clearing groceries list", () => {

    beforeEach( () => {
      component = mount(<GroceryListPart3 />);
    });

    it('Should render required tags', () => {
      try { component.find(".clear-list"); }
      catch(err){
        throw new Error("I can't find 'Clear the List' button");
      }
    });

    it('is possible to remove all list items', () => {

      let clearListButton = component.find(".clear-list");
      clearListButton.simulate('click');
      let groceryListItems = component.find("li");

      assert.equal(groceryListItems.length, 0, "There should be exactly zero elements on the groceries list");
    });
  });
Error: This method is only meant to be run on single node. 0 found instead.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:61 (21 by maintainers)

github_iconTop GitHub Comments

28reactions
hunterpickettcommented, Apr 17, 2018

@BennyHinrichs @ljharb

I wasn’t sure what you meant by trying to find with a reference instead but after a lot of trial and error / googling around I found out that I could select the element using

  const SDP = wrapper.find('withStyles(SingleDatePicker)');

I found the actual display name by digging through the React Chrome extension and finding out it’s exact name.

Though this doesn’t seem like a good solution. Have you found a better one?

18reactions
revikcommented, May 15, 2018

@BennyHinrichs @sanyangkkun - I believe what @ljharb meant is that instead of using the form - wrapper.find('SingleDatePicker') you should remove the quotes (string) and use the component class reference, like so - wrapper.find(SingleDatePicker);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: This method is only meant to be run on single node. 0 ...
I am using Enzyme to simulate the keyup event with the appropriate event data (keycode for esc ) but I come across the...
Read more >
Method “props” is only meant to be run on a single node. 0 ...
This test returns this error no matter what I do, including rewriting this file 10 different ways and using different methods in enzyme:....
Read more >
JavaScript React - Elvenware
We can then display state to the user in the render method: ... Here is the error: Method “props” is only meant to...
Read more >
Simulate is meant to be run on 1 node = 0 found-Reactjs
Jest/Enzyme Error: "Method 'setState' is only meant to run on a single node. 3 found instead." UnitTests in React - Method “text” is...
Read more >
enzymejs/enzyme - Gitter
Error: This method is only meant to be run on single node. 0 found instead. ... Looks like I can only find based...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found