问题标签 [jasmine2.0]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
234 浏览

angularjs - 为什么在嵌套的 beforeEach 中不执行添加的模拟模块

我有以下规格:

正如评论所提到的,赋予 addMockModule 的函数永远不会在浏览器中执行。

现在,如果我在 parent中移动addMockModule调用,模拟模块将被添加并执行。beforeEachdescribe

为什么 ?

0 投票
1 回答
1940 浏览

javascript - React Jest:如何获取复选框的状态

我正在尝试checked在 React 组件中查找复选框的状态。这是我的组件:

我编写了以下测试场景:

当我尝试获取 的值时cb['checked'],它只是打印出一个空字符串''。我期待得到true

获取复选框状态的正确方法是什么?

0 投票
1 回答
106 浏览

javascript - Is it possible to change protractor event queue or control flow?

I am working on an automation project where we are using protractor and jasmine2 for automating our angularjs+nodejs app. So as part of automation I have a scenario where I need to upload a file and just after clicking the file upload button, while the upload is on progress, I need to click on another button and validate something. And when I execute my script, protractor is waiting by itself until the upload process is complete to perform further steps. Is there anyway to handle this? Means after clicking the upload button, script need to perform the next action without even waiting for the upload to complete.

I am sure that this is something related to the control flow, where the promises are added to the event queue. Is there any way to change protractor's event queue?

0 投票
4 回答
3804 浏览

selenium - 量角器片状

我维护一个复杂的 Angular (1.5.x) 应用程序,该应用程序正在使用 Protractor (2.5.x) 进行 E2E 测试。我在使用这种方法时遇到了问题,主要表现为测试看起来不稳定。在一个拉取请求中运行良好的测试在另一个请求中失败。这涉及简单的定位器,例如 by.linkTest(...)。我调试了失败的测试,应用程序位于正确的页面上,链接存在且可访问。

有没有其他人遇到过这些一致性问题?知道原因或解决方法吗?

0 投票
2 回答
3341 浏览

angularjs - 量角器:注册新用户后,如何期望浏览器 url 等于具有 id 的 url?

我正在 Protractor 中进行一些测试并遇到了一个小问题:

我做了一个测试来注册一个新用户,当我完成注册它的 url 将是这样的:

所以,我的问题是,我怎样才能设法让新用户的 ID 在我的测试中得到一个真实的?像这样的东西:

我怎样才能做到这一点?如果可以的话当然可以。

0 投票
2 回答
711 浏览

protractor - Protractor jasmine2-protractor-util TypeError:无法读取未定义的属性“forEach”

我对单独的量角器规格有疑问。我试图划分 1 测试 1 规范。并收到一条错误消息,例如

E/launcher - Cannot read property 'forEach' of undefined E/launcher - TypeError: Cannot read property 'forEach' of undefined at C:\Users\mako\AppData\Roaming\npm\node_modules\jasmine2-protractor-utils\reporter\jasmine2_reporter.js:112:24 at Array.forEach (native) at self.jasmineDone (C:\Users\mako\AppData\Roaming\npm\node_modules\jasmine2-protractor-utils\reporter\jasmine2_reporter.js:108:16) at dispatch (C:\Users\mako\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1966:28) at ReportDispatcher.jasmineDone (C:\Users\mako\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1 949:11) at C:\Users\mako\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:758:18 at QueueRunner.clearStack (C:\Users\mako\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:660:9) at QueueRunner.run (C:\Users\mako\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1881:12) at C:\Users\mako\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1898:16 at C:\Users\mako\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1842:9 E/launcher - Process exited with error code 199

测试用例运行正常,所有套件完成后发生错误。如果规范超过“它”甚至是空的,问题就会消失。你有什么想法可能是什么问题吗?

0 投票
1 回答
754 浏览

javascript - Jasmine 测试 .load() 以获取被调用的 URL

我有一个加载模板的函数,我想检查是否调用了正确的 URL。

因为除了监视 ajax 调用之外我找不到任何信息,我假设调用是一样的.load()。我正在使用茉莉花 2.4.1

功能

茉莉花测试

当我运行此测试时,我收到以下错误:

TypeError:无法读取未定义的属性“mostRecent”

有不同的方法可以做到这一点吗?我还想检查是否调用了成功函数,但直到可以检查 URL 是否正确我不能这样做。

0 投票
1 回答
401 浏览

html - protractor-jasmine2-screenshot-reporter 生成的 Html 报告中缺少表格显示

当我使用 protractor-jasmine2-screenshot-reporter 运行测试以生成 html 报告时,我的报告会以非表格格式创建:

报告

概括

测试的总规格:1 总失败:0 angularjs 主页待办事项列表(4 秒)

✓should add a todo(4 s) 切换配置

如何创建更好的报告,其中显示包含所有结果的表格?

这是我的 conf.js 文件:

非常感谢,

0 投票
1 回答
93 浏览

node.js - 是否有任何用于比较文件的 jasmine 自定义匹配器?

是否有任何 Jasmine 2 的开源自定义匹配器可以执行以下操作:

  • 测试文件是否存在/不存在
  • 测试目录是否存在/不存在
  • 比较文件的内容以查看它们是否匹配/不匹配
  • 将文本字符串与文件内容进行比较以查看它们是否匹配/不匹配
  • 测试一个文件是否与另一个文件新/旧/相同年龄
  • 测试文件是否具有给定的大小

我没有使用 jQuery 或 Angular,也不想要依赖于大型框架的库。

我的应用程序是为 Node.js 编写的,而不是浏览器。

0 投票
0 回答
351 浏览

javascript - Jasmine 获取当前规格测试结果

在 jasmine v2.1.1 中,我曾经:

var passed = jasmine.getEnv().currentSpec.results().passed();

但是更新到 Jasmine v2.5.2 后,我不能再这样做了……看起来currentSpec已经停产了。如果不使用自定义报告器,我如何知道测试是否通过?