nathanboktae / chai-dom

DOM assertions for the Chai assertion library using vanilla JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

False negatives if element is in shadowDom

bennypowers opened this issue ยท comments

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;