gpt4 book ai didi

javascript - Dojo 1.9 和 Intern 1.7 - require.on 未定义?

转载 作者:行者123 更新时间:2023-12-02 17:15:11 25 4
gpt4 key购买 nike

Dojo 1.9Intern 1.7

我在使用 Intern 时遇到了问题,因为它报告 require.on 未定义,并且我的测试套件失败了。

只有在尝试定义包含小部件的测试时才会发生这种情况。看起来当需要小部件包时,它会命中 require.on("idle", onload) 行,但会失败,因为 require.on 未定义。

作为测试,我定义了 require.on 并且测试没有失败。

我能想到的是,当需要使用实习生的小部件时,实习生附带的 dojo 版本会干扰正常的 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 的默认安装情况并非如此。您有两个选择:

  1. 升级到 Dojo 1.9.3 或更高版本。 (推荐。)
  2. 使用 useLoader 配置选项从 Dojo 1.9 副本中指向 dojo.js:
define({
// ...
useLoader: {
'host-browser': 'path/to/dojo1.9/dojo.js'
}
})

关于javascript - Dojo 1.9 和 Intern 1.7 - require.on 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24494698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com