假设我有我的 awesome.html 文件
<head>
<script .. abc-library.js>
<script .. app.js>
</head>
我想对我自己的文件进行单元测试,app.js.
但在我的内部app.js,我正在调用定义的东西abc-library.js,这样说
...
handy_function_from_abcjs("do something here");
...
当然,当我awesome.html在浏览器中加载 my 时,它可以正常工作,因为我定义了 my handy_functionbefore app.js,所以我app.js看到了......
但是,当我在 上运行单元测试时出现问题app.js,因为它只能单独加载app.js,并且会因为找不到handy_function' 定义而失败。
在那些 javascript 单元测试定义中如何解决这种情况?这总是遇到吧?
当我karma用来测试我的初学者 AngularJS 应用程序时,我现在遇到了这个问题。