POST
|
Doh! I finally figured out what was going on here. I left out a key detail to this flow... I'm using VS2012 for my IDE, and I was accessing the test runner through my browser while I had the site running in debug mode. I guess that it wasn't obvious to me from the mocha-phantomjs examples that I needed to access the runner through a web server and not simply through the local file system (which is what I was doing). When I point mocha-phantomjs to the test runner debug site everything works fine. Thanks very much for the examples. I'm going to use those to get started on setting up my project to work with npm, grunt, and dojo builds.
... View more
10-11-2013
11:50 AM
|
0
|
0
|
614
|
POST
|
Thanks for all the info Rene! I tried to flip the order like you suggested and it broke (the working in-browser version) because it couldn't find a module that was listed in the config. I'm guessing that's because the config gets loaded after dojo and doesn't get applied? For full disclosure, here are the contents of the rest of the files... dojoConfig: var dojoConfig = {
paths: {
'jscore': location.pathname.replace(/\/[^/]+$/, '') + '/../../node_modules/jscore',
'widgets': location.pathname.replace(/\/[^/]+$/, '') + '/../../node_modules/widgets',
'text': location.pathname.replace(/\/[^/]+$/, '') + '/../../node_modules/jscore/require/text',
'styles': location.pathname.replace(/\/[^/]+$/, '') + '/../../node_modules/jscore/require/styles',
'template': location.pathname.replace(/\/[^/]+$/, '') + '/../../node_modules/jscore/require/template',
'mapapp': location.pathname.replace(/\/[^/]+$/, '') + '/../../src/mapapp',
'test': location.pathname.replace(/\/[^/]+$/, '') + '/../../test'
}
}; test module: define(["mapapp/MapApp"], function (MapApp) {
'use strict';
describe("MapApp", function () {
it("MapApp should be defined", function () {
expect(MapApp).not.to.be.undefined;
});
});
}); Runs just fine in a browser, just not in PhantomJS...
... View more
10-10-2013
12:22 PM
|
0
|
0
|
614
|
POST
|
I've managed to get unit testing up and running in my project using a combination of mocha, chai, and sinon (our company standard JS testing libraries). This all works perfectly fine when launching unit tests from within a regular browser. However, things go awry when i try to run these tests from within a headless browser (PhantomJS using mocha-phantomjs). In this case, i get the following error: ReferenceError: Can't find variable: require Here's what I'm doing to run the tests: <html> <head> <title>Unit tests</title> <link href="../../node_modules/mocha/mocha.css" rel="stylesheet" type="text/css" /> </head> <body> <script src="../../config/dojo.test.config.js"></script> <script src="//js.arcgis.com/3.7compact/"></script> <div id="mocha"></div> <script> require(["../../node_modules/chai/chai.js", "../../node_modules/mocha/mocha.js", "../../node_modules/sinon/lib/sinon.js"], function (chai) { mocha.setup('bdd'); mocha.reporter('html'); expect = chai.expect; require(["test/unit/MapApp"], function () { if (window.mochaPhantomJS) { mochaPhantomJS.run(); } else { mocha.run(); } }); }); </script> </body> </html> Why are the testing libraries pulled in through a require? Originally I had chai, mocha, and sinon referenced in script tags, but I kept getting multipleDefine errors from the dojoLoader. The dojo documentation says this about the error: [INDENT]AMD define was called referencing a module that has already been defined. The most common cause of this problem is loading modules via <script> elements in the HTML document. Use the loader; don't use <script> elements. The second most common cause is passing explicit module identifiers to define; don't do this either.[/INDENT] After moving these scripts to a require call, everything worked fine in IE, FF, Chrome, etc. It seems like something very fundamental is going wrong here since require is undefined when the code is run from phantomjs. Does anyone have any experience with running automated unit tests using this setup? Any suggestions from the ESRI folks? I'd be open to trying another solution that works w/ mocha. Thanks. ///Donnie
... View more
10-10-2013
10:34 AM
|
0
|
5
|
3360
|
POST
|
Using custom modules with our API is definitely possible, the key is to tell Dojo where to find your stuff, which you do via dojoConfig.packages (or dojoConfig.paths, slightly simpler syntax). What does your dojoConfig look like? Can you provide an example of a url for your app, where the JS API lives and where your custom modules live? So, that part seems to be working fine. I have the packages/paths defined in the dojoConfig. The problem seems to be in that if the modules that are referenced in the dojoConfig have been "optimized" using rjs, there are bits that don't get picked up by the Dojo loader. The inverse is true when trying to load the "built" ESRI modules with the requirejs loader. I think that the problem is that each framework takes a different approach to optimization (i.e. how they combine, consolidate, and reference modules that have been optimized). Please correct me if I'm mistaken about any of this. There doesn't seem to be a lot of info out there about this specific issue - this link is about all I've been able to find. I'm working on getting access to "unoptimized" code for some of my internal libraries which should allow me to use them w/ the Dojo loader. I think it would be nice if ESRI did the same... gave access to "un-built" versions of the API for scenarios like this. There are bound to be plenty of people that are going to want to integrate the ESRI API into an existing application/process that is already leveraging another AMD loader. I can't provide a link to any examples that are using our internal toolset. I'll see if I can put together a trivial example of this and post a link at some point soon. The other part of my problem is that we have an internal build automation tool that automates JavaScript optimization, testing, and many other things. All of these steps are currently dependent on requirejs, so it's looking like I'm now going to have to tear apart our standard builder and create a special build process specifically to accomodate the ESRI API... not exactly ideal. Again, I think that if I had access to an "un-built" version of the ESRI API, none of these problems would exist. Thanks for your help.
... View more
10-08-2013
05:07 AM
|
0
|
0
|
360
|
POST
|
Update on my progress: While I was able to make some pieces of our internal toolkit work reasonably well with the ESRI API (and Dojo loader), I'm going to have to perform some serious surgery on many other pieces. I basically have a scenario where our entire framework (core sdk, ui widget system, unit testing, application loading/management) has a dependancy on our AMD loader (because many components of our framework are built with rjs). It seems like the inverse of this situation (ESRI API being a Dojo "build" and thus having a dependancy on the Dojo loader) is why I'm having trouble loading our internal modules using the ESRI loader... In other words, we have internal "optimized" modules that the Dojo loader doesn't know how to find and the ESRI API has "built" modules that we don't know how to find. We are a very large organization that has an internal framework and library in place so that everyone is building client apps in a common, consistent manner, and it seems that I'm going to have to deviate greatly from this in order to accommodate the ESRI API. It seems unlikely to me that I would be the only one to ever run across this scenario, so I think it would be a great idea for ESRI to consider providing an "unoptimized"/unbuilt version of the API for greater ease of integration with existing JavaScript apps. At the very least, I think that it's an invalid assumption that forcing consumers of the ESRI API to use the Dojo AMD loader is inconsequential. For my situation, it's obviously causing huge headaches. I apologize if there are any inaccurate assumptions about optimized AMD module loading in this post. In fact, if there are, please straighten me out. 🙂
... View more
10-07-2013
09:58 AM
|
0
|
0
|
360
|
POST
|
Have you looked at using Dojo's loader to load your require plug-ins? I'm not sure if they're compatible but it's worth trying: http://livedocs.dojotoolkit.org/loader/amd#plugins What do your current requirejs plug-ins do? Okay, it turns out that those plugins were compatible with the dojo loader. I just needed to create a dojoconfig that pointed to the plugins in the paths property. It seems to be working for me now. Thanks for your help.
... View more
09-26-2013
12:49 PM
|
0
|
0
|
360
|
POST
|
Have you looked at using Dojo's loader to load your require plug-ins? I'm not sure if they're compatible but it's worth trying: http://livedocs.dojotoolkit.org/loader/amd#plugins What do your current requirejs plug-ins do? Thanks, I'll take a look. It looks like the plugins mostly read in external files as text, css, etc.
... View more
09-26-2013
11:30 AM
|
0
|
0
|
630
|
POST
|
What does requirejs do that you can't do with the Dojo module loader? My problem is that we have a company-internal toolkit that includes a handful of require.js plugins that are to be used as part of our web client "standard". It means that, unless there is some quick and easy way to make these same plugins work with dojo, it's going to be very hard for me to integrate an esri map into apps that are built with our in-house toolkit.. Being new to the game, I don't know if that's even feasible yet.
... View more
09-26-2013
10:46 AM
|
0
|
0
|
630
|
POST
|
Spent another few minutes on Google, found this: http://stackoverflow.com/questions/17475515/using-requirejs-with-dojo-1-9-1 Hope this helps. Thanks. So, it sounds like you cannot use another loader with the esri api at the moment because it is a "built" version of dojo. I guess that means I'll need to use the dojo loader or nothing. That's disappointing. Hopefully this changes in a future release.
... View more
09-26-2013
08:51 AM
|
0
|
0
|
630
|
POST
|
I'm sure you saw: http://requirejs.org/docs/dojo.html Which leads to: https://bugs.dojotoolkit.org/ticket/15616 Since the ticket discussed there is resolved, it should be possible. Some great comments further down; they should lead you in the right direction. Thanks - I did see that. However, I'm very new to dojo and I'm not sure which comments are relevant. I require a little more hand-holding at this point. 🙂
... View more
09-26-2013
07:14 AM
|
0
|
0
|
630
|
POST
|
I need to use the esri API within a JavaScript app that is built using require.js + backbone + others (all are a part of a standard internal company toolkit). Does anyone have any examples of how this can be done? I have done some searching on this forum and the internet in general and can't seem to find any concrete examples of how to make this happen. I should clarify that I have tried to make this happen and can't seem to prevent the AMD loaders from stepping on each other. Thanks. Donnie Holmes
... View more
09-26-2013
05:56 AM
|
0
|
17
|
1931
|
POST
|
You can instantiate a simple renderer and set the symbol property to the graphic symbol. Then by calling QueryLegendInfos on this renderer, you will get the imagesource as a property of the legendItemInfo (only one legenditeminfo is returned by a simple renderer) Thanks very much! That did the trick.
... View more
04-08-2013
06:19 AM
|
0
|
0
|
244
|
POST
|
Does anyone have any sample code for converting the Symbol of a Graphic into an ImageSource (similar to what is displayed on the Legend control)? What i'm trying to do is display selected items from the map in a listbox and show the symbol used for the item next to the display name (similar to the Legend Symbol). This is fairly easy if the layer uses a single symbol, but it's not so easy in the case of a unique value renderer. I have looked into simply leveraging the ILegendSupport.QueryLegendInfos call, but the return data does not contain information that is suitable for use as a unique id (In the case of a unique value renderer, only the label and description for each symbol is exposed and not the underlying values that are used). Any ideas are appreciated - Thanks.
... View more
04-05-2013
12:13 PM
|
0
|
3
|
451
|
POST
|
FYI... this is also an issue when rotating any graphic (v2.4).
... View more
08-13-2012
11:28 AM
|
0
|
0
|
108
|
POST
|
I've stumbled accross a bug in the EditGeometry class. It seems that if you edit an Envelope geometry, the SpatialReference property will get nulled after an edit. I can work around this issue for now - I just thought I would report it.
... View more
06-26-2012
07:30 AM
|
0
|
1
|
397
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|