test suite paths when using ArcGIS JSAPI as an alternate loader in intern

最后都变了- 提交于 2019-12-05 02:30:41

问题


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.

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'
],

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).

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.

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.

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.


回答1:


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/' }
    /* … */
});

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 … */
    };
});


来源:https://stackoverflow.com/questions/19524299/test-suite-paths-when-using-arcgis-jsapi-as-an-alternate-loader-in-intern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!