我得到错误,
未找到具有 testID 的实例:CreateAccount.errorMessage
但我在“CreateAccount.js”上引用了 ID
<ErrorText
text={this.state.errorMessage}
testID="CreateAccount.errorMessage"
/>
然后在“CreateAccount.test.js”
test("display error msg if all fields are not completed", () => {
const { getByTestId, getByText } = render(<CreateAccount />);
fireEvent.press(getByText("Submit"));
console.log(getByTestId("CreateAccount.errorMessage").props);
});
我的组件缺少什么以使 testID 正常工作?
提前致谢