A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/stdavis/intern-tutorial-esri-jsapi below:

stdavis/intern-tutorial-esri-jsapi: Using intern to unit/functional test your esri JavaScript API apps.

intern-tutorial-esri-jsapi

This is a tutorial on using intern to unit/functional test your esri JavaScript API apps.

First off big props to Colin Snover over at sitepen for the intern-tutorial found here. Colins tutorial was my starting point and helped me get the feel for intern and writing the tests themselves. I highly recommend you read his tutorial first, then come back here.

For a fast start running my example tests, follow these steps:

cd <path to the tutorial>
npm install intern-geezer
http://<path to the tutorial>/intern-tutorial-esri-jsapi/node_modules/intern-geezer/client.html?config=tests/intern

Important notes for esri jsapi integration:

The key to making intern work with the esri jsapi is two fold:

  1. You have to use intern-geezer due to a bug in dojo 1.8.3 and below. Esri jsapi 3.6 is based on dojo 1.8.3. If your looking to support old IE (8 and below) you need to use intern-geezer anyway.

  2. Defining the intern loader to work with the esri jsapi. Intern uses a local copy of dojo core. As such you need to tell it where to find the esri jsapi. Do this in your intern config file:

loader: {
        // Packages that should be registered with the loader in each testing environment
        packages: [{
			name: 'app',
			location: 'app'
		}, {
			name: 'gis',
			location: 'gis'
		}, {
			name: 'esri',
			location: 'http://js.arcgis.com/3.6/js/esri'
		}, {
			name: 'dojo',
			location: 'http://js.arcgis.com/3.6/js/dojo/dojo'
		}, {
			name: 'dojox',
			location: 'http://js.arcgis.com/3.6/js/dojo/dojox'
		}, {
			name: 'dijit',
			location: 'http://js.arcgis.com/3.6/js/dojo/dijit'
		}]
	}

You also need to add the locations to your custom modules you want to load and test. In the above example 'app' and 'gis' is where we have some modules to test.

Important notes for intern usage:
  1. Intern-geezer only supports intern/chai!assert. When the esri jsapi moves to 1.8.4 or higher, you can switch to regular intern and take advantage of intern/chai!expect and intern/chai!should. Esri jsapi 3.6 is based on dojo 1.8.3 but 3.7 will be based on dojo 1.9.1.
  1. tests\hello.js This test comes from Colins tutorial and is very simple, the hello world of intern.

  2. tests\extent.js This test demonstrates using the esri Extent and Point classes from the api.

  3. tests\map.js This test demonstrates the async testing method. This will be the most common test method as most apps need to wait for objects to load before they can be used. For example esri/map.

  4. tests\printWidget.js This test demonstrates how to use two objects that require waiting until their on load fires before testing. This also shows how to use the async method a little differently than map.js test. For more info on async tests read here.

  5. tests\functional\index.js This test comes from Colins tutorial is is the hello world for functional testing.

Intern has docs located in the wiki of the intern repo. Read them. While not comprehensive it does outline everything needed.

Chai doc can be found here.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4