Javascript Dojo 1.9和Intern 1.7-require.on未定义?
及 我和Intern有一个问题,因为它报告说,Javascript Dojo 1.9和Intern 1.7-require.on未定义?,javascript,dojo,intern,Javascript,Dojo,Intern,及 我和Intern有一个问题,因为它报告说,require.on没有定义,我的测试套件正在崩溃 只有在尝试定义包含小部件的测试时才会发生这种情况。看起来,当重新请求小部件包时,它会点击一行require.on(“idle”,onload),但失败,因为require.on未定义 作为测试,我在上定义了require.on,测试不会结束 我所能想到的是,intern附带的dojo版本在要求使用intern的小部件时干扰了正常的dojo模块 以下是我的测试的简化版本: define([ "
require.on
没有定义,我的测试套件正在崩溃
只有在尝试定义包含小部件的测试时才会发生这种情况。看起来,当重新请求小部件包时,它会点击一行require.on(“idle”,onload)
,但失败,因为require.on
未定义
作为测试,我在上定义了require.on,测试不会结束
我所能想到的是,intern附带的dojo版本在要求使用intern的小部件时干扰了正常的dojo模块
以下是我的测试的简化版本:
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;
}
});
});
以下是我的配置:
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\//
});
文件夹结构为:
app/
libs/
dojo
dijit
intern
test/
unit/
exampleTest.js
intern.js
我直接从google chrome浏览器运行测试:
http://{webroot}/app/libs/intern/client.html?config=../test/intern
我确实有一些测试成功运行,但不包括任何小部件
感谢您的帮助。您运行的是一个过时的Dojo 1.9版本,该版本希望使用的AMD加载程序是Dojo 1.9附带的加载程序,而Intern的默认安装并非如此。您有两个选择:
升级到Dojo 1.9.3或更高版本。(推荐)
使用useLoader
configuration选项从dojo 1.9的副本指向dojo.js:
定义({
// ...
useLoader:{
“主机浏览器”:“path/to/dojo1.9/dojo.js”
}
})