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

feat: upgrade to JSDOM 16 #9606

Merged
merged 19 commits into from
May 2, 2020
Merged

Conversation

lh0x00
Copy link
Contributor

@lh0x00 lh0x00 commented Feb 21, 2020

Summary

Fix #9507 by using new version of jsdom. PR should be merged to jest@26 or a jest version supported node >= 10 (a requirement in jsdom).

Test plan

Green CI with node >= 10 and write new e2e tests to check leaking memory.

@lh0x00 lh0x00 requested a review from SimenB February 21, 2020 05:12
@lh0x00 lh0x00 changed the title Upgrade JSDOM 16 WIP: Upgrade JSDOM 16 Feb 21, 2020
@SimenB
Copy link
Member

SimenB commented Feb 21, 2020

We'll want getVmContext as well https://github.com/SimenB/jest-environment-jsdom-sixteen/blob/fd898842676e8f888feddbf4c4af81a3517e0306/index.js#L104

@lh0x00 lh0x00 changed the title WIP: Upgrade JSDOM 16 Upgrade JSDOM 16 Feb 21, 2020
@lh0x00
Copy link
Contributor Author

lh0x00 commented Feb 21, 2020

I added getVmContext and it seems tests is passed (node >= 10).

@SimenB
Copy link
Member

SimenB commented Feb 21, 2020

The circus run complains about a memory leak. Is it correct or flake?

@lh0x00
Copy link
Contributor Author

lh0x00 commented Feb 22, 2020

It's ok because we know jest-circus is leaking by self, ref #8816.

@irega
Copy link

irega commented Mar 18, 2020

With the last change, I guess the PR it's ready to review @SimenB @mindblight

Thanks so much!

@SimenB
Copy link
Member

SimenB commented Mar 18, 2020

As mentioned multiple times before, this cannot be merged until we're ready to make breaking changes, which we're not at the moment. It requires dropping node 8.

This PR also introduces a memory leak

@vibaiher
Copy link

Since jsdom 16 adds support to custom elements, this PR also enables users to test their custom web components like this:

import MyCustomElement from './MyCustomElement'

describe('Playlist', () => {
    beforeEach(() => {
        window.customElements.define('my-custom-element', MyCustomElement)
    })

    it('attributes are empty by default', () => {
        const customElement = document.createElement('my-custom-element')
        
        customElement.setAttribute('title', 'My Custom Title')

        expect(customElement.shadowRoot.querySelector('.title').innerHTML).toBe('My Custom Title')
    })
})

@AviVahl
Copy link

AviVahl commented Mar 31, 2020

[email protected] has memory and handle leak fixes that might be relevant to this PR.

@SimenB SimenB mentioned this pull request Apr 17, 2020
@SimenB SimenB added this to the Jest 26 milestone Apr 23, 2020
@SimenB
Copy link
Member

SimenB commented May 1, 2020

This should be rebased now that we've fixed the memory leak in circus.

EDIT: I merged in master now

@SimenB
Copy link
Member

SimenB commented May 1, 2020

Note to self, remember to merge #9938 after landing this

Copy link
Member

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@SimenB SimenB changed the title Upgrade JSDOM 16 feat: upgrade to JSDOM 16 May 2, 2020
@SimenB SimenB merged commit bc31829 into jestjs:master May 2, 2020
jeysal added a commit to jeysal/jest that referenced this pull request May 2, 2020
…hile-running

* upstream/master: (331 commits)
  chore: update ts-eslint (jestjs#9953)
  Updated config docs with default transform value (jestjs#8583)
  Update jest-phabricator documentation (jestjs#8662)
  chore: remove dependency on `realpath-native` (jestjs#9952)
  chore: bump dated dependencies (jestjs#9951)
  chore: another try at fixing test-utils dependency
  chore: update lockfile due to beta release
  chore: move changelog entry and fix tets utils dependency
  Fix time duration formatting as per SI (jestjs#9765)
  v26.0.0-alpha.0
  chore: run some jsdom tests in leak check (jestjs#9938)
  chore: upgrade chalk to v4 (jestjs#9752)
  feat: upgrade to JSDOM 16 (jestjs#9606)
  chore: remove checks for compileFunction (jestjs#9949)
  chore: drop node 8 support  (jestjs#9423)
  Remove leftover `providesModuleNodeModules` (jestjs#9948)
  [BREAKING] Pojer -> Nakazawa
  chore: revert lockfile changes from 2b32fe6
  chore: move changelog entry and fix lint
  Remove `providesModuleNodeModules` from Jest. (jestjs#9583)
  ...
Comment on lines +50 to +52
// In the `jsdom@16`, ArrayBuffer was not added to Window, ref: https://github.com/jsdom/jsdom/commit/3a4fd6258e6b13e9cf8341ddba60a06b9b5c7b5b
// Install ArrayBuffer to Window to fix it. Make sure the test is passed, ref: https://github.com/facebook/jest/pull/7626
global.ArrayBuffer = ArrayBuffer;
Copy link
Contributor

@ExE-Boss ExE-Boss Nov 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is wrong, since it causes the newly‑created global to have the ArrayBuffer constructor from the outer realm, whereas jsdom/jsdom@3a4fd62 made it so that the inner realm has its own ArrayBuffer constructor and prototype chain.


Refs: #10786, #10854

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ExE-Boss great! Wanna send a PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v25] --detectLeaks option always reports a leak when using jsdom environment
9 participants