将ArcGIS JSAPI用作实习生中的备用加载程序时的测试套件路径 [英] test suite paths when using ArcGIS JSAPI as an alternate loader in intern

查看:100
本文介绍了将ArcGIS JSAPI用作实习生中的备用加载程序时的测试套件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ArcGIS Javascript API构建的应用程序,我一直在使用实习生添加测试。我在开发过程中在Windows 7的IIS下运行它。在开始使用实习教程正常工作https://stackoverflow.com/questions/17788908/how-to-specify-alternate-loader-for-intern\">如何为实习生指定备用加载程序我能够在client.html中设置加载程序到< script src =http://js.arcgis.com/3.7/>< / script> 我可以让我的测试运行但只有在我更改了查询字符串和intern.js中的路径以包含IIS中定义的父路径之后。

I have an application built using ArcGIS Javascript API and I've been adding tests using intern. I run it under IIS in Windows 7 while developing. I had no trouble getting the intern tutorial working when getting started and after looking at How to specify alternate loader for intern I was able to set the loader in client.html to <script src="http://js.arcgis.com/3.7/"></script> and I was able get my tests running but only after I changed the path in both the query string and in intern.js to include the parent path as defined in IIS.

例如,假设我的应用程序托管在 http:// localhost / testApp / mySite ,我有js mySite位置中定义的,css,tests和node_modules文件夹。
要运行测试,我必须转到 http://localhost/testApps/mySite/node_modules/intern/client.html?config = mySite / tests / intern mySite 添加到配置位置。
同样,在我的配置中,我必须像这样定义我的套件:

For example, say my app is hosted at http://localhost/testApp/mySite and I have js, css, tests, and node_modules folders defined in the mySite location. To run the tests I would have to go to http://localhost/testApps/mySite/node_modules/intern/client.html?config=mySite/tests/intern prepending mySite to the location of the config. Likewise, in my config, I had to define my suites like so:

suites: [
    'mySite/tests/suite1',
    'mySite/tests/suite2',
    'mySite/tests/suite3'
],

如果我不更改脚本标记以在client.html中使用不同的加载器并在node_modules中使用dojo的版本,那么我不需要额外的路径(但找不到esri库)。

If I don't change the script tag to use a different loader in client.html and use the version of dojo in node_modules then I don't need to have the extra path (but the esri library cannot be found).

我也发现了实习生教程的esri jsapi版本,在该教程中,他不必更改加载器。
不同之处在于,由于dojo 1.8.3中的错误,他正在使用intern-geezer,但我使用的是esri jsapi 3.7,因此有dojo 1.9.1而且我也不关心旧IE,所以我宁愿如果我不需要,不要使用geezer。我确实用他的方式在intern.js中指定了我的包。

I have also since found the esri jsapi version of the intern tutorial and in that tutorial he does not have to change the loader. Difference is that he is using intern-geezer due to a bug in dojo 1.8.3 but I'm using esri jsapi 3.7 and thus have dojo 1.9.1 and I also don't care about old IE so would rather not use geezer if I don't have to. I did specify my packages in intern.js the same way he did.

我确实拿了我的应用程序副本并安装了intern-geezer而不是实习生我能够运行测试。除了一个之外的所有人都通过了(我怀疑这是因为geizer中没有支持chai的东西)而且我根本不需要修改路径。 client.html的intern-geezer版本与实习生不同。它没有使用require。

I did take a copy of my app and installed intern-geezer instead of intern and I was able to run the tests. All but one passed (I suspect it to be because of something from chai not being supported in geezer) and I didn't have to modify the paths at all. The intern-geezer version of client.html is different from that in intern. It doesn't use require.

有没有办法让我可以使用esri jsapi实习,而无需在client.html中更改加载器?我想以自动方式从命令行运行。

Is there a way I can get intern to work with esri jsapi without having to change the loader in client.html? I would like to have this run from the command line in an automated fashion as well.

推荐答案

从Intern 1.3开始,您可以指定其他加载器,例如来自Esri的加载器,在 useLoader 配置属性中。对于Esri加载器,您可以使用:

As of Intern 1.3, you may specify alternative loaders, such as the one from Esri, in the useLoader configuration property. For the Esri loader, you would use this:

// intern.js
define({
    /* … other configuration options … */
    useLoader: { 'host-browser': 'http://js.arcgis.com/3.7/' }
    /* … */
});

注意Esri使用旧的Dojo 1加载器;如果要指定其他 dojoConfig 条件,如 async:true 等,请添加 dojoConfig 配置文件中的全局对象:

Note that Esri uses the old Dojo 1 loader; if you want to specify additional dojoConfig criteria like async: true, etc., add the dojoConfig global object within your configuration file:

define([], function () {
    this.dojoConfig = { async: 1 };

    return {
        /* … configuration … */
    };
});

这篇关于将ArcGIS JSAPI用作实习生中的备用加载程序时的测试套件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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