DavidSpriggs / intern-tutorial-esri-jsapi

Using intern to unit/functional test your esri JavaScript API apps.
25 stars 12 forks source link

Intern 1.3 updates #4

Closed csnover closed 10 years ago

csnover commented 11 years ago

Just wanted to let you know that the newly released version of Intern should be much easier to use with Esri’s bundled code. You can use http://js.arcgis.com/<version>/ as the loader defined in the configuration at useLoader['host-browser'].

If you were to take the intern-tutorial as-is and do this, the one gotcha is that you need to put var dojoConfig = { tlmSiblingOfDojo: false }; at the top of your Intern configuration file, or you need to register 'tests' as its own package, because of the way the Dojo 1 loader resolves non-packaged module paths by default. This is nothing specific to Intern, just an annoying quirk of the Dojo loader.

DavidSpriggs commented 11 years ago

Awesome! Thanks for the update! I will give this a go!

tomwayson commented 11 years ago

@csnover - thanks for the update! I tried your suggestion using the intern-tutorial with mixed success.

First I set host-browser': 'http://js.arcgis.com/3.7' in intern.js and added var dojoConfig = { tlmSiblingOfDojo: false }; to the top of node_modules/intern/client.js. I was able to load and run the tests/hello suite no problem.

Then I copied over the gis package that @DavidSpriggs created, added a reference under 'loader.packages' as follows:

        packages: [
            { name: 'app', location: 'app' },
            { name: 'gis', location: 'gis' }
        ]

I then copied over his suites to the tests folder and ran them. In the browser (client.html) all but tests/printWidget ran. At the command line (client.js) none of them ran. In each case, the loader is looking for modules in the wrong place.

Did I configure the loader correctly?

Tom

robertd commented 11 years ago
robertd commented 11 years ago

Bump...

tomwayson commented 11 years ago

@robertd

I had updated my fork of this repo to use 3.7:

https://github.com/tomwayson/intern-tutorial-esri-jsapi

But that's still using geezer. I think I tried to get it to use intern (non geezer) but it didn't work without any changes and I didn't dig into it. Then I saw @csnover's response above and tried to get 3.7 working in the intern-tutorial repo with mixed success (see above).

In short - I think it can be done w/ some tweaking, but I haven't had time to try beyond the above.

FYI - I'm using Karma for my day to day testing of Esri JS apps based on this boiler plate, and it's working well for me:

https://github.com/tomwayson/esri-karma-tutorial

Tom

robertd commented 11 years ago

@tomwayson

Thanks Tom. I'm going to stick with esri-karma template for now. :+1:

I was able to use latest Intern with local copy of esri jsapi, but I was unable to make it work with useLoader['host-browser'] option. Let me know if you wan't me to publish that setup in case you need it.

Thanks!

csnover commented 11 years ago

Sorry, I have been having trouble with GitHub sending notifications to the wrong email address because they have two different places for email settings. Now that I have fixed that, I should actually respond to things now.

@tomwayson You will probably need to configure the locations of all packages—dojo, dijit, esri, etc. It depends upon what the default package settings of the Esri build are. I am not intimately familiar with this code to say for sure. The loader configuration from https://github.com/DavidSpriggs/intern-tutorial-esri-jsapi#important-notes-for-esri-jsapi-integration should be what is needed. If you can say specifically which modules are failing, where they are supposed to load from, and where they are actually loading from, then maybe there is a clue for a solution there.

I am not aware that any of Esri APIs are intended to be usable from directly within Node.js so it would not surprise me a lot if running client.js just doesn’t work at all.

DavidSpriggs commented 10 years ago

I got this all working with esrijs 3.7 and intern 3.7 by following @csnover tips. Interestingly, esrijs 3.6 also worked fine. I updated the repo and readme to reflect the changes. Thanks to all who helped out on this thread.

tomwayson commented 10 years ago

@csnover - thanks for the reply! Took me a while to get my repo synced and test out the update @DavidSpriggs made. Glad to see this working w/ intern 1.3

I think I was confused about 2 things:

  1. I thought setting host-browser: 'http://js.arcgis.com/3.7' would make it so that would not have to configure the package locations
  2. I didn't realize that client.js was for testing node apps. I thought it was a runner to automate browser testing by kicking off a server and opening up browsers - akin to the Karma runner. Makes much more sense that client.js is for node and client.html is for browser. :)
csnover commented 10 years ago

I’m glad that it is working for you as well. Please let me know if there is anything else that we can do to make Intern work better for you.