The property:
@track showDesktopView = false;
I've tried the below appproaches of setting the property, but they don't work.
const element = createElement('c-test', { is: testLWC });
element.showDesktopView = "true"; //Trial 1
element.showDesktopView = true; //Trial 2
document.body.setAttribute('showDesktopView','true'); //Trial 3
document.body.appendChild(element);
return Promise.resolve().then(() => {
// My promise code
});
They don't seem to work since my Promise fails. I know my code in the Promise works because if I set the property "showDesktopView" to a default value of true, then it passes.
Does anyone know how to correctly set this property from a Jest unit test?4 respuestas
I do use this.template.querySelector in my code in certain places (not jest test) and it definitely functions correctly.In my jest test, the element.shadowroot.querySelector does work if I default showDesktopView to true. The test case passes, it finds the name value.I also found this in my jest test, if I use element.querySelector when default showDesktopView is true, the case fails.