在玩笑和酵素中检查按钮文字

时间:2019-08-19 09:19:02

标签: javascript reactjs react-native jestjs enzyme

我有以下本机测试代码。

if (!!activeConnections[testID]) {      
  logger.info("reconnected..");

  clearTimeout(activeConnections[testID].timeout);

} else {
  activeConnections[testID] = {};
  socket.candidateTestId = testID;
  activeConnections[testID].testSubmitted = false;
  activeConnections[testID].candidateTestId = testID;
  activeConnections[testID].timeout = undefined;
}

socket.on("disconnect", function () {
  callTimeOutToSubmitTest(socket.candidateTestId, socket);
});

这不能正常工作。我要检查的是按钮文本。 我该怎么办?

1 个答案:

答案 0 :(得分:5)

我认为我们需要将.props替换为.props(),而且toEqual的语法也应该像这样-:

expect(wrapper.find(BorderlessButton).props().text).toEqual('D');