1

I have an problem accessing the __data__ attribute when doing tests in PhantomJS.

Basically, I just want to do

var lineChart =  $compile('<div line-chart></div>')($rootScope);
$rootScope.$digest();
expect($(lineChart).find('.lines path')[0].__data__.value.length).toBe(27);

It works fine in chrome, but not in PhantomJS. Looks like the phantomJS only work if using .eq(1) .html() etc so I switch to

$(lineChart).find('.lines path').eq(0).__data__)

to grab the element but it still doesn't work.

Does anyone know how to grab the d3 __data__ attribute within PhantomJS?

1
  • a workaround would be to use d3 selector, like d3.selectAll('.lines path')[0][0].__data__ But to do this, you have to create a d3 container to wrap everything, which is not convenient for testing directive. Still curious about how to access the private(_) variable in PhantomJS?
    – ichbinjeff
    Apr 23, 2014 at 19:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.