【发布时间】:2020-11-28 19:11:28
【问题描述】:
我正在使用 vue-test-utils 和 jest 测试 Vue.js 2 组件。该组件自动将焦点设置到特定元素。 JSDom 应该指向 document.activeElement 变量中的这个元素,但即使我使用 wrapper.find(...).element.focus() 在测试中手动设置焦点,它也只会指向 body 元素。
it('focuses the default option automatically', async () => {
const wrapper = await mount(component);
console.log(document.activeElement); // -> <body></body>
// expect(document.activeElement.value).toBe('none');
});
【问题讨论】:
标签: javascript vue.js jestjs jsdom