I have a d3 graph with force enabled and I want to test the position is as expected after a drag action.
This is the force function:
var simulation = d3.forceSimulation()
.force("center", d3.forceCenter().x(width / 2).y(height / 2))
.force("charge", d3.forceManyBody().strength(1))
.force("collide", d3.forceCollide().strength(.1).radius(30).iterations(1))
simulation
.nodes(data)
.on("tick", function(d){
node
.attr("cx", function(d){ return d.x; })
.attr("cy", function(d){ return d.y; })
});
Testing with
cy.get('svg circle').eq(0)
.should('have.attr', 'cx', '342.0317014443128')
The problem is the position attributes of the elements never stop changing, due to the force simulation.