Error: This method is only meant to be run on single node. 0 found instead.
See original GitHub issueClearly 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:
- Created 8 years ago
- Comments:61 (21 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
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?
@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);