0

我有一个父母在专注时为孩子们设置了一种风格。当我编译我的反应项目时,它完美地工作。

我正在使用reactemotion,但这没关系,因为最后我有通常的css。

  const parentStyle = css`
    :focus {
      #child {
        border: 2px solid blue !important;
      }
    }
  `;

我想从子元素中获取边框样式。

我正在使用 jest 来测试这个,我尝试了这样的事情。

parent.simulate('focus');
const childNode = wrapper.find("#child");
const computedStyles = window.getComputedStyle(childNode);
expect(computedStyles.getPropertyValue('border')).toBe('2px solid blue');

所以期望失败了,它没有得到边框样式。

4

0 回答 0