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.

[Clover] jsdom: Mocks for element scrolling methods are missing

See original GitHub issue

I’m not sure if Clover is at a stage where you accept issues/PRs 😃 , so let me know if we should wait until you are over a certain point.

But one of the problems† I see is that some scrolling methods are not yet implemented in jsdom like scrollTo. https://github.com/jsdom/jsdom/blob/master/lib/jsdom/browser/Window.js#L900

Which causes the server build to fail if a lib uses such a method.

Error: Not implemented: window.scrollTo
    at module.exports (<path/to/project>/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
    at <path/to/project>/node_modules/jsdom/lib/jsdom/browser/Window.js:866:7
    at rt.scrollToPosition (http://http/main.b51ee99a0a5badf2c7a5.js:1:111539)
    at c._next (http://http/main.b51ee99a0a5badf2c7a5.js:1:513321)
    at c.__tryOrUnsub (http://http/main.b51ee99a0a5badf2c7a5.js:1:1113718)
    at c.next (http://http/main.b51ee99a0a5badf2c7a5.js:1:1112947)
    at u._next (http://http/main.b51ee99a0a5badf2c7a5.js:1:1112126)
    at u.next (http://http/main.b51ee99a0a5badf2c7a5.js:1:1111900)
    at t.next (http://http/main.b51ee99a0a5badf2c7a5.js:1:1109640)
    at triggerEvent (http://http/main.b51ee99a0a5badf2c7a5.js:1:498683) undefined

There is already an issue filled… https://github.com/jsdom/jsdom/issues/1422

…with an open PR: https://github.com/jsdom/jsdom/pull/2626

The question is: Should we mock it for Clover for now or wait and see? For example:

// server-engine.ts
 dom = new JSDOM(htmlContent, {
        runScripts: 'dangerously',
        resources: customResourceLoader,
        url: options.url,
        referrer: options.headers?.referrer as string | undefined,
        userAgent: options.headers?.['user-agent'] as string | undefined,
        beforeParse: (window) => {
          window.ngRenderMode = true;
          
          // TODO: remove it after https://github.com/jsdom/jsdom/pull/2626 is merged
          const noop = () => {};
          Object.defineProperty(window, 'scrollTo', { value: noop, writable: true });
          ...
        },
      });

† Another problem is routing.

🌍 Your Environment

Angular CLI: 12.0.0
Node: 12.18.0
Package Manager: yarn 1.22.10
OS: darwin x64

Angular: 12.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, platform-browser
... platform-browser-dynamic, platform-server, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1200.0
@angular-devkit/build-angular   12.0.0
@angular-devkit/core            12.0.0
@angular-devkit/schematics      12.0.0
@angular/fire                   6.1.4
@nguniversal/builders           12.0.0
@nguniversal/common             12.0.0
@schematics/angular             12.0.0
rxjs                            6.6.6
typescript                      4.2.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

2reactions
alan-agius4commented, May 15, 2021

I think I might know what’s happening. I’ll take a look at this earlier next week.

0reactions
angular-automatic-lock-bot[bot]commented, Jun 20, 2021

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to spy on window.scrollTo in Jest? - javascript
In jest the global name space must be accessed by global not window . global.scrollTo = jest.fn().
Read more >
typeerror: cannot read property 'location' of undefined jest
i'm trying to wrap the wrapper and the error is gone, but i caught another ... With this approach, the side effect of...
Read more >
Untitled
Brain parts description, 250 lbs to 160 lbs, Art et technique du lavis, ... Download files on iphone jailbreak, Element 99 is named...
Read more >
Untitled
Stoicheia elements, Boo puppy, Molino nixtamal precio, Brent richards, Rocknet broadband ... Vincenzo raiola twitter, Multidisciplinary approach dictionary, ...
Read more >
Untitled
Granatos live planas, Neymar boots gold, Keputusan pru 10 pahang, Clover irish ... Qc sports club membership, Horizontal scrolling div html5, Baby boutique ......
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