Closed ahayes91 closed 4 years ago
@ahayes91 this seems like a bug with one of the type convertors. As a workaround see if either passing datetime as a long ( e.g (new Date()).getTime()
) or using a testWrapper component (which creates the component under test via its markup) gets you unblocked. I'll try posting back a work-item number for your future reference.
Thanks @esalman-sfdc! Passing as a long works as a workaround - is there a reason why? Could you also explain how the testWrapper component works/throw me a link for reference?
We logged a bug for this issue (W-5377882) and it is scheduled to be fixed in Spring '19.
I'm trying to create a component in a lightning test with a required "DateTime" attribute, and getting an internal server error.
Example component "egAttributeTypes" has a "Date" example that works fine, but DateTime doesn't seem to work at all.
Steps to recreate: (Optional) Update jasmineTests.app to run only $Resource.jasmineExampleTests. Change "dateAtr" in egAttributeTypes to a DateTime type as per the following:
See results below.
It also fails in mochaTests.app.
I also tried different methods of setting the dateAtr in jasmineExampleTests.resource, like "2018-07-13T10:26:15.000Z" and "$A.localizationService.formatDate(new Date(), "MMMM DD YYYY, hh:mm:ss a");", but no luck.
There is a workaround if your DateTime attribute is not required on load of the component - in the spec you can remove setting the attribute from the "attributes" object and inside $T.createComponent, you can use component.set("v.dateAtr",new Date()); and it works fine. But if your attribute is required, this won't work.