karma: Bug: window scrolling
I would like to use testacular for testing a window-scroll-related utility.
There seems to a bug wherein I cannot get correct scrolling behaviour. Given this code:
chai.should()
describe("foo", function () {
it("bar", function () {
$('body').append('<div id="foo"></div>')
$('#foo').css('height', 3000)
dump(window.innerHeight)
window.innerHeight.should.equal(300)
window.scrollY.should.equal(0)
window.scrollTo(window.scrollX, 50)
window.scrollY.should.equal(50)
});
});
I get the unexpected error:
info (watcher): Changed file "/Users/jasonkuhrt/projects/components/scroll-over/test.js".
PhantomJS 1.7 DUMP: 300
PhantomJS 1.7 foo bar FAILED
expected 0 to equal 50
at /Users/jasonkuhrt/projects/components/scroll-over/node_modules/chai/chai.js:258
at assertEqual (/Users/jasonkuhrt/projects/components/scroll-over/node_modules/chai/chai.js:662)
at /Users/jasonkuhrt/projects/components/scroll-over/node_modules/chai/chai.js:2780
at /Users/jasonkuhrt/projects/components/scroll-over/test.js:15
PhantomJS 1.7: Executed 1 of 1 (1 FAILED) (0.031 secs / NaN secs)
The specific assertion failing is:
window.scrollY.should.equal(50)
I am able to make this test pass with mocha-phantomjs. Whatโs going on in this testacular context?
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 18 (4 by maintainers)
Wrapping aroung window.setTimeout did the trick. thx ๐
Got it working ๐