我想用jasmine进行单元测试javascript应用程序。我的应用程序使用requirejs。我找到了Jasmine maven plugin
此插件适用于非requirejs应用程序。它还有requirejs模板,但我无法使用maven成功运行测试用例。
我已将样本测试用例编写为
#!/bin/sh
#/etc/init.d/kuuyi
### BEGIN INIT INFO
# Provides: kuuyi
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Kuuyi
### END INIT INFO
case "$1" in
start)
/usr/local/bin/forever --sourceDir=/home/pi/kuuyi_device -p /root/.forever run.js
;;
stop)
/usr/local/bin/forever stop --sourceDir=/home/pi/kuuyi_device run.js
;;
*)
echo "Usage: /etc/init.d/kuuyi {start|stop}"
exit 1
;;
esac
exit 0
如果我将testcase包装在requirejs中,那么maven将不会在requirejs块中执行代码。如果我在requirejs(第一行)中提供不存在的js文件,则会抛出该文件不存在的错误。
我尝试了很多方法将jasmine(requirejs)与maven集成,但无法找到任何其他插件或任何解决方案。
答案 0 :(得分:0)
我需要在define block
中包装describe,而不是在require块中包装describe方法
define(['model'],
function(Model) {
describe('Test description new', function() {
it('some test', function(done) {
expect(1 + 2).toBe(4); //it throw error
});
});
});