Open LucaMele opened 4 years ago
Since 2.3.0
Jest throws TypeError: The custom element constructor's prototype is not an object.:
From my insights it seems that two different Object
constructors are being used, which causes this check to fail.
https://github.com/webcomponents/polyfills/blob/75717f84bbb6ba165dacbf6c406da5845bcb9664/packages/custom-elements/src/CustomElementRegistry.js#L168-L173
Reproduction Repo with relevant analysis in PR description: https://github.com/axa-ch/jest-test-plib-v2/pull/1
Lock down to 2.2.10
to mitigate this type error:
https://github.com/axa-ch/jest-test-plib-v2/pull/2
Hey! Any progress with this issue?
If you are using @webcomponents/custom-elements
lock down to version ^1.2.4
If you don't actually need the customElements to return an actual element and you're only aiming to avoid this error, you can can mock the implementation.
Create a config file for jest that will be included in all tests as part of a setupFiles option.
setup-globals.js
window.customElements = {
define: () => {},
};
// jest.config.js
....
setupFiles: [
'<rootDir>/YOUR-PATH/setup-globals.js',
],
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
https://github.com/axa-ch/patterns-library/issues/1452
https://github.com/axa-ch/jest-test-plib-v2/pull/2