question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: window scrolling

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hydhavalcommented, Jun 3, 2015

Wrapping aroung window.setTimeout did the trick. thx 👍

1reaction
neilbaylorcommented, Jun 3, 2015

Got it working 😄

it('becomes "fixed" when scrolling past the break point', function (done) {
    var node = React.findDOMNode(component);
    document.body.style.height = '10000px';
    document.body.appendChild(node.parentNode); //this is the key
    window.scrollTo(0, component.SCROLL_BREAK_POINT + 1);
    window.setTimeout(function () {
        expect(window.getComputedStyle(node).position.toLowerCase()).toEqual('fixed');
        document.body.style.height = '';
        document.body.removeChild(node.parentNode);
        done();
    }, 150)
  });
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Windows 10 scrolling by itself - SoftwareKeep
Do you have a problem with "Windows 10 scrolling by itself." This is annoying. In this guide, we highlight steps you can follow...
Read more >
Weird scrolling glitch - Microsoft Community
The PC keeps scrolling up by itself, but it is not in all programs (I notice it happens in microsoft store apps, the...
Read more >
Windows 10 Keeps Scrolling Down Automatically - [SOLVED]
How To Solve If Windows 10 Keeps Scrolling Down Automatically? · FIX 1: Change Windows Settings For Your Mouse · FIX 2: Check...
Read more >
FIX: Windows 10/11 Scrolling down on its own. - wintips.org
Method 1: Disable 'Scroll inactive windows when hovering over them' option. This problem has been reportedly resolved by changing the Mouse settings. 1....
Read more >
Windows Scrolling On Its Own? Try These Fixes
Besides this, it could also be a Windows bug causing the automatic scroll. If the issue is due to the PC receiving a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found