How to test if element has focus in ember component test?

842 Views Asked by At

I am writing component test that I am testing if the element has focused. I tried using the document.activeElement in order to accomplish this however, I am getting mix results sometimes the assert fails sometimes the asserts succeeds. Is there another strategy to test focus?

1

There are 1 best solutions below

2
On

with https://github.com/simplabs/qunit-dom

you can just do

assert.dom(selector).isFocused();