jpoiri
jpoiri

Reputation: 367

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

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?

Upvotes: 1

Views: 931

Answers (1)

NullVoxPopuli
NullVoxPopuli

Reputation: 65173

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

you can just do

assert.dom(selector).isFocused();

Upvotes: 3

Related Questions