简体   繁体   English

如何使用 Protractor 为 ReactJS 应用程序测试和编写测试用例?

[英]How to test and write test cases for ReactJS app with Protractor?

I have been trying to test my own React app with Protractor but I don't know the correct syntax of test cases.我一直在尝试使用 Protractor 测试我自己的 React 应用程序,但我不知道测试用例的正确语法。 I searched few things like:我搜索了几件事,例如:

await browser.waitForAngularEnabled(false);

The command is useful but still I don't know how to write test cases for React app.该命令很有用,但我仍然不知道如何为 React 应用程序编写测试用例。 The tutorials are available for Angular only, like for example how to click on a certain button, how to write in input box, how to verify test result, how to match values, how to get title, etc.教程仅适用于Angular,例如如何点击某个按钮,如何在输入框中写入,如何验证测试结果,如何匹配值,如何获取标题等。
Kindly guide me in this because I need Protractor for it.请指导我,因为我需要 Protractor 。 Thank you in advance.先感谢您。

The nice thing about protractor is it isn't really language specific. protractor 的好处在于它不是真正特定于语言的。 You can test react pages just like any other page.您可以像测试任何其他页面一样测试反应页面。 Make sure to set ignoreSynchronization before you visit a non angular page and all those tutorials should work.确保在访问非 angular 页面之前设置 ignoreSynchronization,所有这些教程都应该有效。

// if true, ignore synchornization for testing non-angular pages.
browser.ignoreSynchronization = true;

You may have to replace the angular waits with your own.您可能必须用自己的替换 angular 等待。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM