salesforce / sfdx-lwc-jest

Run Jest against LWC components in SFDX workspace environment
MIT License
165 stars 82 forks source link

[LWC warn]: Unknown public property * of element *. This is either a typo on the corresponding attribute "*", or the attribute does not exist in this browser or DOM implementation. #306

Closed AllanOricil closed 1 year ago

AllanOricil commented 1 year ago

Description

Why does this warning message appear if the property is in the child element?

@nolanlawson could you help to understand why this issue happens. I know this "warning" happens in the following module, but I can't figure out the problem

at patchProps (/Users/allanoricil/sf-metadata/node_modules/@salesforce/sfdx-lwc-jest/node_modules/@lwc/engine-dom/dist/engine-dom.cjs.js:3788:21)

child

child.js

....
@api
userData

parent

parent.js

....
userData = {}

parent.html

<template>
   <c-child user-data={userData}></c-child>
</template>

Version

Possible Solution

none

Additional context/Screenshots

image

AllanOricil commented 1 year ago

the userData prop is declared in the child and exposed using @api, but when running tests, the engine-dom.cjs can't find this public property in the elm. This is how the child element is used in the parent component.

image

image

In this image you can see the moment when the warning appears for the userData property of the child component. image

In the following images you can see that accountData and recordData properties are present in the elm, while the prop called userData isn't.

image

image

image

AllanOricil commented 1 year ago

In this image you can see that the userData prop is in vnode.data.

image

Why isn't theuserData prop present in elm like the other two properties, if all three props are exposed with @api?

AllanOricil commented 1 year ago

A mock was used instead of the actual component. And userData was missing in the mock... image image