Thanks for the quick response Mike!
I had actually explored both of those options earlier, but neither seemed ideal because:
1.) By asynchronous testing, I'm assuming this involves letting the transition run in real time. Unfortunately this wouldn't work if there are a large number of these tests (or long transition durations), as the test cases would take a very long time to run.
2.) I think Option 2 would be ideal, except for one issue.
window.requestAnimationFrame = function(callback) { /** My custom logic. */ };
This will have no effect on the 'setFrame' variable - it's too late, the original version of 'requestAnimationFrame' has already been used in the assignment of 'setFrame'.
One possible workaround for this would be to override 'requestAnimationFrame' before d3 is loaded, but that doesn't seem ideal, as that would mean that all unit tests would be affected, and we wouldn't be able to selectively apply the requestAnimationFrame override for only the relevant tests.
A small internal change which I believe could fix this, would be to just have a private function (not a public API) in d3-timer which returns requestAnimationFrame for internal use, instead of storing it on initialization:
function getSetFrame() {
return typeof requestAnimationFrame === "function" ? requestAnimationFrame : function(f) { setTimeout(f, 17); };
}
Let me know your thoughts on this, or if there is something I'm missing here.
Thanks!