测试表单时,我使用 userEvent 在文本框中键入“hello”,然后在使用 toHaveValue() 直接测试所述文本框的值时,它向后返回字符串...
render(<Form />)
userEvent.clear(screen.getAllByRole('textbox')[0])
userEvent.type(screen.getAllByRole('textbox')[0], 'hello')
expect(screen.getAllByRole('textbox')[0]).toHaveValue('hello')
Run Code Online (Sandbox Code Playgroud)
包版本:
"react-scripts": "^3.4.3",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.1.9",
Run Code Online (Sandbox Code Playgroud) 我正在使用 CRA 4,当使用带有样式组件的关键帧时,百分比会导致错误,我似乎无法理解为什么 - 但如果我使用 To / From 不会出错。
这是示例:
import styled, { keyframes } from 'styled-components'
const animateLeft = keyframes`
0% {
opacity: 1
}
50% {
opacity: 0.4;
}
100% {
opacity: 1;
}
`
Run Code Online (Sandbox Code Playgroud)
在样式组件中使用,如下所示:
animation: ${animateLeft} 1s infinite;
Run Code Online (Sandbox Code Playgroud)
我得到的关键帧内百分比的错误是:
} expectedts-styled-plugin(9999)
Run Code Online (Sandbox Code Playgroud)
为什么?