如何在Karma / Jasmine中包含PHP文件来运行测试? [英] How to include PHP file to run test in Karma/Jasmine?

查看:193
本文介绍了如何在Karma / Jasmine中包含PHP文件来运行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试的JS文件在没有PHP应用程序的情况下是无用的,因为我的应用程序的后端会生成我的JS应用程序使用的所有DOM元素和数据。

The JS file I want to test is useless without PHP app on top of which it executes, because backend of my app generates all the DOM elements and data, which my JS app utilizes.

换句话说,如果我写 my.conf.js

files: [
      'app.js',
      'spec/test.js'
      ],

app.js 会抛出大量有关未找到元素的错误,例如表格,图形容器等。

app.js will throw tons of errors regarding not found elements, like tables, graph containers, etc.

因此,我需要以某种方式将我的整个应用程序包含在测试中。也许通过包含我的应用程序的主 index.php ?在Karma / Jasmine有可能吗?或者我宁愿设置某种重定向?

Because of that I need to include my whole app to the test somehow. Perhaps by including my app's main index.php? Is it possible in Karma/Jasmine? Or do I rather set some kind of redirect?

推荐答案

@xmike的评论是有效的,但如果你要坚持你可以使用 Karma的代理商配置

The comment by @xmike is valid, but if you were to insist you can use Karma's proxies configuration.

这篇关于如何在Karma / Jasmine中包含PHP文件来运行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆