Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mocks for element scrolling methods #1422

Closed
just-boris opened this issue Mar 21, 2016 · 6 comments
Closed

Add mocks for element scrolling methods #1422

just-boris opened this issue Mar 21, 2016 · 6 comments
Labels

Comments

@just-boris
Copy link

Element prototype has several methods to scroll it, but those methods are commented in the sources.

Why did you do this? For example window.scrollTo is a function that does nothing, just prints warning in console. I think that it would be okay for Element.prototype.scroll() method as well.

@domenic
Copy link
Member

domenic commented Mar 21, 2016

PR welcome

@domenic domenic added the feature label Jul 2, 2016
sloria added a commit to microfeedback/microfeedback-button that referenced this issue Jan 24, 2018
sleepycat added a commit to cds-snc/ircc-rescheduler that referenced this issue Aug 24, 2018
This is a workaround for jsdom/jsdom#1422. This just prevents a bunch of
console.error output from cluttering the test results.
sleepycat added a commit to cds-snc/ircc-rescheduler that referenced this issue Aug 24, 2018
This is a workaround for jsdom/jsdom#1422. This just prevents a bunch of
console.error output from cluttering the test results.
dsamojlenko pushed a commit to cds-snc/ircc-rescheduler that referenced this issue Sep 1, 2018
This is a workaround for jsdom/jsdom#1422. This just prevents a bunch of
console.error output from cluttering the test results.
@M3kH
Copy link

M3kH commented Nov 12, 2018

How far is this issue to be close?

@thenikso
Copy link

thenikso commented Mar 8, 2019

I also needed this, I ended up doing something like this:

const el = dom.window.document.querySelector(
    '.myScrollingElement',
  );
el.scrollTop = 12345;
el.dispatchEvent(new dom.window.Event('scroll'));

@jordantomax
Copy link

jordantomax commented May 22, 2019

This affecting me to. I've tried many variations of overriding it, such as:

Object.defineProperty(window.Element.prototype, 'scrollIntoView', {
  writable: true,
  value: jest.fn()
})

But I either get an error that I can't override, or it does nothing. Am I doing something wrong?

@jessethomson
Copy link

I know this is old, but are you all still open to a PR to change this?

If scrollX, scrollY, etc are all hardcoded to 0, it seems like it makes sense that scroll, scrollBy, and scrollTo functions on the window object are just stubs. Let me know!

#2626

@domenic
Copy link
Member

domenic commented May 27, 2023

We need to tackle this problem comprehensively. Let's roll discussions into #2751.

@domenic domenic closed this as completed May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants