Currently, I am in the process of testing a Vue.js 2 component using a combination of vue-test-utils
and jest
. One functionality of this component is that it automatically sets focus to a specific element. When examining JSDom, we expect it to reference this element in the document.activeElement
variable. However, even when manually setting focus within the test using
wrapper.find(...).element.focus()
, the active element still only seems to point to the body element.
it('focuses the default option automatically', async () => {
const wrapper = await mount(component);
console.log(document.activeElement); // -> <body></body>
// expect(document.activeElement.value).toBe('none');
});