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

Please provide window.customElements to be able to test custom Web Components #8818

Closed
stefaneidelloth opened this issue Aug 13, 2019 · 8 comments

Comments

@stefaneidelloth
Copy link

stefaneidelloth commented Aug 13, 2019

I would like to test some custom web components. Chromium supports commands like

window.customElements.define('my-custom-element', MyCustomElementClass);

to register a custom web component.

However, window.customElements does not seem to be known in the context of jest tests.

=> Please allow to test custom web components directly with jest.

Also see related SO question:

https://stackoverflow.com/questions/57478484/how-to-test-custom-web-component-with-jest/57481761#57481761

@thymikee
Copy link
Collaborator

This is a request to JSDOM, please send it there.

@SimenB
Copy link
Member

SimenB commented Aug 14, 2019

There is jsdom/jsdom#1030 already (and PR: jsdom/jsdom#2548)

@superwf
Copy link

superwf commented Dec 6, 2019

I think that electron could include both node and chrome together.
so i found this, use electron to replace jsdom
https://github.com/facebook-atom/jest-electron-runner

@awdltd
Copy link

awdltd commented Feb 17, 2020

The current version of jsDom running in Jest is v15.1.1. The latest release of jsDom (16.2.0) includes full support for customElements:
https://github.com/jsdom/jsdom/releases/tag/16.2.0

Any chance this issue be re-opened, and any ETA given for when Jest can bump the version?

@markcellus
Copy link

markcellus commented Feb 17, 2020

@awdltd where did you find the latest jsdom version Jest uses? I know Jsdom is a dependency. Just unsure of where it is explicity declared.

@SimenB
Copy link
Member

SimenB commented Feb 17, 2020

@awdltd you'll need to use jest-environment-jsdom-sixteen until jest@26. Still a few months out I'd guess (haven't thought about it yet)

@mkay581 https://github.com/facebook/jest/blob/1ed46e71a058c93b529e5e3f9388a800352de21a/packages/jest-environment-jsdom/package.json#L18

@awdltd
Copy link

awdltd commented Feb 17, 2020

Hey @mkay581, I checked in my node_modules folder and jest-environment-jsdom is bundled with Jest (I admit I am taking liberties to assume that is what Jest uses by default). The package.json for this has "jsdom": "^15.1.1", so I assume that Jest will automatically use 15.. by default

Thanks for the heads up and the quick response, @SimenB! Fortunately found jest-environment-jsdom-sixteen in the interim and testing in that at the moment 👍

@github-actions
Copy link

This issue 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

No branches or pull requests

6 participants