FuncUnit无法使用PhantomJS运行testing

我一直在尝试创build一系列functionunit testing,使用PhantomJS作为浏览器在Node.js Web服务器上运行,在另一个站点上testingfunction。 过去,我已经使用FuncUnit成功地从目标站点本身运行functiontesting,但为了testing规模,我创build了一个Node项目来执行此操作,在Heroku实例上运行。

我用Bower安装了JQuery,Jasmine(我正在使用的testing运行器)和FuncUnit。 我已经被告知,FuncUnit不支持最新版本的Jasmine,所以它在版本1.3.1 – 所有其他软件包在他们的最新版本。 Phantom已经安装了NPM,并打开了以下页面:

<html> <head> <title>Functional Testing</title> <script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script> <script type="text/javascript" src="bower_components/syn/dist/syn.js"></script> <script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/jasmine.js"></script> <script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/jasmine-html.js"></script> <script type="text/javascript" src="bower_components/jasmine-core/lib/jasmine-core/json2.js"></script> <script type="text/javascript" src="bower_components/funcunit/dist/funcunit.js"></script> <script type="text/javascript" src="testSpec.js"></script> <script type="text/javascript"> // Standard Jasmine 1.3 boot script from examples </script> </head> <body> </body> </html> 

一旦testing运行开始,我几乎立即遇到错误。 下面的部分似乎会导致崩溃,虽然我很难找出哪一行正如堆栈跟踪已certificate难以导航。

 F.attach(jasmine); F.speed = 100; describe("Demo Script", function() { "use strict"; it("should login to the website", function() { F.open("http://example.site/login"); if (F('h2:contains("ALL PROJECTS")').size() === 0) { // Not logged in F('#Email').visible().type("a@b.com"); } }); }); 

这会产生以下说明的错误:

 TypeError: 'undefined' is not an object (evaluating 'off.left') file:///app/bower_components/funcunit/dist/funcunit.js:290 file:///app/bower_components/funcunit/dist/funcunit.js:473 file:///app/bower_components/funcunit/dist/funcunit.js:120 file:///app/bower_components/funcunit/dist/funcunit.js:91 file:///app/bower_components/funcunit/dist/funcunit.js:2852 file:///app/bower_components/funcunit/dist/funcunit.js:3240 

该堆栈跟踪的顶行指向以下函数:

 //syn.helpers.addOffset addOffset: function (options, el) { var jq = syn.jquery(el), off; if (typeof options === 'object' && options.clientX === undefined && options.clientY === undefined && options.pageX === undefined && options.pageY === undefined && jq) { el = jq(el); off = el.offset(); options.pageX = off.left + el.width() / 2; options.pageY = off.top + el.height() / 2; } } 

看来, el被传递到这个函数作为undefined ,但试图调查这个电话的来源已经让我难倒了。 如果任何人都可以看到丢失的脚本引用或任何可能导致此错误的testing规范,那将是非常感激。 谢谢!

编辑

我刚刚注意到,如果我让它继续运行,这个错误每30秒钟就会重新发生一次。

Interesting Posts