如何使用 Cucumber 测试加载 javascript 的内容

发布于 2024-09-28 11:00:24 字数 468 浏览 1 评论 0原文

我一直在开发 Rails 应用程序,并且决定混合实施测试驱动开发和行为驱动开发。

然而,我正在构建的应用程序使用名为 MochaUI 的 Web 应用程序用户界面框架,该框架构建在 Mootools 框架之上。

我刚刚完成了部分单元测试的编写,并开始测试用户界面;这就是我开始遇到问题的地方。

我想测试的很多东西是通过 javascript 加载的内容,一些数据加载到 iframe 中,一些数据加载到元素(ajax)中。

所以我写了一个测试

And I should see "Some text loaded into an iframe with javascript"

,正如你猜的那样,它失败了。我不知道从哪里开始解决这个问题,因为我对 TDD 和 BDD 很陌生,但我正在努力解决这个问题,任何人都可以给我一些指示或可能的解决方案,以便我晚上可以睡觉吗?

谢谢!

I've been developing a Rails application and I've decided to implement a mixture of Test Driven Development and Behavioral Driven Development.

However the application I am building uses a web application user interface framework known as MochaUI which is built on top of the Mootools framework.

I have just finished writing a portion of unit tests and have moved on to testing the user interface; which is where I start to run into problems.

A lot of the things I want to test is content that is loaded via javascript, some data is loaded into iframes, some data is loaded into elements (ajax).

So I wrote a test

And I should see "Some text loaded into an iframe with javascript"

And as you guessed, it failed. I don't know where to begin to fix this problem, as I am very new to TDD and BDD but I'm working my way there, can anyone give me some pointers or possibly a solution so I can sleep at night?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

给我一枪 2024-10-05 11:00:24

使用capybara,用@javascript标记需要javascript的场景。

Use capybara, tagging the scenarios that require javascript with @javascript.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文