问题
Dojo 1.9 and Intern 1.7
I am having a problem with Intern in that it's reporting that require.on
is not defined and my test suite is falling over.
This is only happening when trying to define a test that includes a widget. it looks like when the widget package is requried then it hits a line require.on("idle", onload)
but fails because require.on
is undefined.
As a test, I defined require.on
and the test does not fall over.
All I can think of is that the version of dojo that intern ships with is interfering with the normal dojo module when requiring widgets using intern?
Here is a cut down version of my test:
define([
"intern!object",
"intern/chai!expect",
"dijit/form/Button"
],
function (
registerSuite,
expect,
Button) {
registerSuite({
name: "Simple test",
"failing test for demo" : function (){
expect(true).to.be.false;
}
});
});
Here is my configuration:
define({
// The port on which the instrumenting proxy will listen
proxyPort: 9000,
// A fully qualified URL to the Intern proxy
proxyUrl: 'http://localhost:9000/',
// Default desired capabilities for all environments. Individual capabilities can be overridden by any of the
// specified browser environments in the `environments` array below as well. See
// https://code.google.com/p/selenium/wiki/DesiredCapabilities for standard Selenium capabilities and
// https://saucelabs.com/docs/additional-config#desired-capabilities for Sauce Labs capabilities.
// Note that the `build` capability will be filled in with the current commit ID from the Travis CI environment
// automatically
capabilities: {
'selenium-version': '2.40.0'
},
// Browsers to run integration testing against. Note that version numbers must be strings if used with Sauce
// OnDemand. Options that will be permutated are browserName, version, platform, and platformVersion; any other
// capabilities options specified for an environment will be copied as-is
environments: [
{ browserName: 'chrome' }
],
// Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
maxConcurrency: 3,
// Whether or not to start Sauce Connect before running tests
useSauceConnect: false,
// Connection information for the remote WebDriver service. If using Sauce Labs, keep your username and password
// in the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables unless you are sure you will NEVER be
// publishing this configuration file somewhere
webdriver: {
host: 'localhost',
port: 4444
},
// Configuration options for the module loader; any AMD configuration options supported by the specified AMD loader
// can be used here
loader: {
// Packages that should be registered with the loader in each testing environment
packages: [
{
name: "dojo",
location: "libs/dojo"
}{
name: "dijit",
location: "libs/dijit"
},{
name: "unitTests",
location: "test/unit"
}
]
},
// Non-functional test suite(s) to run in each browser
suites: [ /* 'myPackage/tests/foo', 'myPackage/tests/bar' */
"unitTests/exampleTest"
],
// Functional test suite(s) to run in each browser once non-functional tests are completed
functionalSuites: [ /* 'myPackage/tests/foo', 'myPackage/tests/bar' */
],
// A regular expression matching URLs to files that should not be included in code coverage analysis
excludeInstrumentation: /^tests\//
});
Folder structure is:
app/
libs/
dojo
dijit
intern
test/
unit/
exampleTest.js
intern.js
I am running the test straight from the google chrome browser:
http://{webroot}/app/libs/intern/client.html?config=../test/intern
I do have some tests that run successfully but do not include any widgets.
Thanks for any help.
回答1:
You are running an outdated version of Dojo 1.9 that expects that the AMD loader being used is the one that comes with Dojo 1.9, which is not the case in a default installation of Intern. You have two options:
- Upgrade to Dojo 1.9.3 or later. (Recommended.)
- Use the
useLoader
configuration option to point to dojo.js from your copy of Dojo 1.9:
define({
// ...
useLoader: {
'host-browser': 'path/to/dojo1.9/dojo.js'
}
})
来源:https://stackoverflow.com/questions/24494698/dojo-1-9-and-intern-1-7-require-on-is-not-defined