This repository was archived by the owner on Feb 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Reproduce Jest Type Error #1
Open
AndyOGo
wants to merge
1
commit into
master
Choose a base branch
from
reproduce/jest-pblib-type-error
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Hier it works same example: https://github.com/axa-ch/patterns-library-examples/tree/master/create-react-app. Must be a tiny difference what makes it brake here |
|
@AndyOGo If you need support, please make a meeting. I don't have time ATM to debug your code |
Contributor
Author
Version analysationI analyzed the |
Contributor
Author
|
Alright, I started digging down the prototype chain, and if I’m correct 2 different f = c.prototype;
var fObjectProto = f.__proto__.__proto__.__proto__.__proto__.__proto__.__proto__.__proto__;
var fObjectProtoCtor = fObjectProto.constructor;
console.log(c); // -> [Function: AXAIcon]
console.log(c instanceof Object); // -> true
console.log(f); // -> AXAIcon [HTMLElement] {}
console.log(f instanceof Object); // -> false
console.log(Object); // -> [Function: Object]
console.log(fObjectProtoCtor); // -> [Function: Object]
console.log(fObjectProtoCtor === Object); // -> false
console.log(fObjectProto); // -> {}
console.log({} instanceof Object); // -> true
console.log(fObjectProto instanceof Object); // -> false
console.log(fObjectProto instanceof fObjectProtoCtor); // -> falseLog Output: console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3495
[Function: AXAIcon]
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3496
true
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3497
AXAIcon [HTMLElement] {}
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3498
false
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3499
[Function: Object]
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3500
[Function: Object]
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3501
false
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3502
{}
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3503
true
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3504
false
console.log node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js:3505
false |
Contributor
Author
|
Mitigation of breaking |
This was referenced Oct 22, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Starting a new CRA project with
npx create-react-app foo, using reactified@axa-ch/buttonand writing a shallow test for it throws TypeError: The custom element constructor's prototype is not an object.Related source code of
webcomponentsjspolyfill:https://github.com/webcomponents/polyfills/blob/75717f84bbb6ba165dacbf6c406da5845bcb9664/packages/custom-elements/src/CustomElementRegistry.js#L168-L173
How to reproduce?
reproduce/jest-pblib-type-errornpm run testChecklist Jest and Plib v2
install needed polyfills as described here
@axa-ch/patterns-library-polyfillfor plib v2 componentsmutationobserver-shimuse Jest configuration as described at this commit
setup Jest to use those polyfills
setup Jest to use Enzyme Adapter for React 16
Setup Jest transform files for css, js and other file types
Add
displayNameproperty to reactified@axa-ch/buttonfor Snapshots and Enzyme as described hereshallowrender reactified@axa-ch/buttoncomponentError Log