问题标签 [js-test-driver]
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.
javascript - 如何对与 DOM 元素交互的 Javascript 代码进行单元测试
背景:
我来自 Java 背景,所以对 Javascript 不太熟悉。
我们计划在我们现有的(遗留)代码和未来的工作中引入 JavaScript 单元测试。我们主要是一家java商店(Spring、Weblogic等)。
我们正在寻找能够与 IDE(IntelliJ 理念)和声纳良好集成的选项,以及能够将它们作为持续集成的一部分运行。
JsTestDriver 似乎勾选了所有方框。
问题:
我们现有的许多 javascript 代码 a) 嵌入到 JSP 中,并且 b) 利用 jQuery 直接与页面元素交互。
我们应该如何测试一个严重依赖 DOM 的函数。这是我正在谈论的函数的一些代码示例:
或者
In the latter case, my approach would be that the function in question is way too large and should be broken to smaller (units) so that it can be tested. But all the interaction points with DOM, jQuery, datatables, ajax etc makes it really complicated to refactor things in the way we do in Java world to make it more testable.
So, any suggestions for the above to sample cases would be greatly appreciated!
javascript - 运行无头 JsTestDriver?
有没有办法在无头状态下使用 jsTestDriver,它加载浏览器但无头(你看不到浏览器)或加载它们最小化?
qunit - 将 QUnit 与 JSTestDriver 适配器 (QUnitAdapter.js) 一起使用时版本不匹配
我正在尝试使用 jsTestDriver 运行用 QUnit 编写的单元测试。我收到“ReferenceError:未定义相等”。查看源码可知适配器(Qunit->jsTestDriver)QUnitAdapter.js支持equals方法:
而 Qunit 不支持 equals (去年重命名为 equal)。
我在这里错过了什么吗?
ps 我正在使用集成到 WebStorm 4 中的 jsTestDriver。
linux - JsTestDriver 火狐浏览器崩溃
我刚开始使用 JsTestDriver,我创建了非常简单的演示代码来查看我是否正确配置了我的环境。然而,当 Firefox 启动(通过 JsTestDriver)“Firefox 启动时意外关闭”时,大约 40-50% 的时间我会收到以下错误。
如果我使用 Chrome,则不会出现此错误。
我的环境包括:
- VirtualBox 4.1.18 运行 Ubuntu 10.04.4 LTS 32bit
- 火狐 13.0.1
- JsTestDriver-1.3.4.b
- openjdk-6-jre-headless
我正在执行:
java -jar /home/developer/bin/JsTestDriver.jar --port 9876 --browser /usr/bin/firefox --tests all --testOutput results
我的 JsTestDriver 配置是:
源代码(正在测试的代码)是:
测试代码(基于 JsTestDriver 的代码)是:
谢谢!
unit-testing - 在没有浏览器的情况下运行 jstd-maven-plugin 测试
我已经启动并运行了jsTestDriver,并且我使用jstd-maven-plugin在构建期间运行测试。
该插件需要指定浏览器才能工作,我想使用类似rhino或htmlunit的东西,它们实际上不会启动浏览器。
jasmine-maven-plugin使用htmlunit执行此操作,并且效果很好。
有没有办法为jstd-maven-plugin指定一个无头浏览器?
unit-testing - JsTestDriver - 缺少工件错误
我正在尝试将JsTestDriver集成到Maven以在部署之前测试我的脚本。实际上,我在此处遵循 Google Code 中描述的步骤。但不幸的是,我无法解决依赖问题。尽管我在 Maven settings.xml中添加了存储库和插件存储库,但我仍然收到错误“缺少工件 com.googlecode.jstd-maven-plugin:jstd-maven-plugin:jar:1.3.2.5 ”。
如果有人可以纠正/指导我,我会很高兴。
提前致谢。
带着敬意。
设置.xml
pom.xml
google-chrome - 无法使用 Cygwin 从 Jenkins 运行 Chrome
我正在使用 Cygwin(在我的系统路径的前面)在 Windows XP 上使用 Jenkins 在本地测试 JsTestDriver。
Jenkins 调用一个 .sh 脚本,其中包含以下内容:
当包含谷歌浏览器时,詹金斯作业停止,我最终在控制台输出中得到这个错误:
如果我尝试在 Cygwin 中运行 Google Chrome,它可以工作,但我收到以下消息:
问题是我将 Jenkins 作为 Windows 服务运行并且它无法运行 Chrome,因为它需要以我的身份运行(我的用户配置文件)?
javascript - 从 JS 测试驱动程序代码覆盖中排除依赖项
在我的 JS 测试驱动程序配置文件中,我通过将单元测试放在test
而不是load
.
但是,我不能为依赖项执行此操作,例如 Underscore.js 的 jQuery,因为它们需要在我的代码之前加载。
有没有办法解决?还是我只是处理缓慢的代码覆盖运行和统计混乱?
javascript - 在 jsTestDriver 中递归查找文件
有没有人想出解决 jsTestDriver 无法递归查找文件以从配置进行测试的方法。它记录在这里:http ://code.google.com/p/js-test-driver/issues/detail?id=6
目前我们无法在 jsTestDriver 配置中提供 /root/module/** 之类的内容。
unit-testing - 为什么 JsTestDriver 会创建第二个浏览器实例?
我打开 FireFox 并转到捕获 URL(默认为 localhost:9876/capture)。
然后我通过 jstestdriver 运行我的 jasmine 测试。
输出说:
即使在运行测试之前,如果我在 Firefox 上单击“关闭”,jstestdriver 注册为已关闭一个实例,但我仍然看到浏览器打开。打开捕获和/或服务器后,似乎有两个 Firefox 实例正在运行。
任何想法为什么会发生?