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

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

问题描述

我有一个使用 ArcGIS Javascript API 构建的应用程序,并且我一直在使用实习生添加测试.我在开发时在 Windows 7 的 IIS 下运行它.我在开始和查看 如何为实习生指定备用加载器 我能够在 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 并且我在 mySite 位置定义了 js、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 而不是 intern,我能够运行测试.除了一个都通过了(我怀疑这是因为 geezer 不支持来自 chai 的某些东西)而且我根本不需要修改路径.client.html 的 intern-geezer 版本与 intern 中的不同.它不使用 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 开始,您可以在 useLoader 配置属性中指定替代加载器,例如来自 Esri 的加载器.对于 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天全站免登陆