New to LWC and Jest -- and trying to write a succinct test on a component with multiple lightning-input elements.
I have used the following pattern, which works fine -- I get a passing result:
let allInputs = element.shadowRoot.querySelectorAll('lightning-input');
allInputs.forEach(input => {
if (input.name === 'zip') {
expect(input.value).toBe('97214');
}
});
The following would be much shorter, but I get "TypeError: Cannot read property 'value' of null":
let zipInput = element.shadowRoot.querySelector('lightning-input[name="zip"]');
expect(zipInput.value).toBe('97214');
Seems like these two should work the same way. Why not?