nathanboktae / chai-dom

DOM assertions for the Chai assertion library using vanilla JavaScript
Other
76 stars 26 forks source link

False negatives if element is in shadowDom #22

Open bennypowers opened 7 years ago

bennypowers commented 7 years ago

In some cases, elements in shadowDom will fail even though they are hidden.

Fails with Error: expected section#activity[hidden] to not be displayed, but it was as 😠

test('Auth view should be visible by default', () => {
  initialState.$.activity.should.not.be.displayed;
});

Passes! 🍻

// NOTE: Passes!
test('Auth view should be visible by default', () => {
  window.getComputedStyle(initialState.$.activity).display.should.contain('none');
});

I propose changing chai-dom.js:279 to:

actual = el.style.display || window.getComputedStyle(el).display;