问题标签 [envjs]

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 回答
552 浏览

javascript - 使用 env.js 在 Rhino 中锚元素的路径名返回 undefined

我遇到了一个问题,我认为这源于 Rhino 中锚标签的实现。虽然我正在使用env.js,但我怀疑我可能没有正确配置某些东西。

特别是,当我尝试针对为 angularjs 应用程序编写的代码编写单元测试时,会出现我的问题。当我包含angular.js(版本 1.2.1 到现在)时,我收到以下错误:

TypeError: Cannot call method "charAt" of undefined

我确信错误是此调用的结果,urlParsingNode.pathname因为console.log调用显示pathname对象未定义。

urlParsingNode我跟踪到这一行的实例化,我们看到它是对document.createElement("a"); 进一步向下的调用的结果,我们看到他们在这一行href中设置了属性,希望创建的锚标记将利用浏览器正确解析 URL .

我必须相信我不是第一个尝试通过 Rhino 对 Angular 进行 JS 单元测试的人,但到目前为止,我还没有成功地用谷歌搜索自己的解决方案。任何提示将不胜感激。