I think the problem is with $document. You need to define which document and find the body element and attach to that. This code passes for me now in PhantomJS, by replacing $document
with angular.element($document[0].body)
.
it('works with element height', inject(function ($document) {
var el = angular.element('<div>Lorem ipsum...</div>')[0];
//Find the correct body element
angular.element($document[0].body).append(el);
// size of non-empty block element should be non-zero by default
expect(el.clientHeight).to.not.equal(0);
expect(el.scrollHeight).to.not.equal(0);
// it should certainly be non-zero after the height is set manually
el.style.height = '999px';
expect(el.clientHeight).to.not.equal(0);
expect(el.scrollHeight).to.not.equal(0);
}));