【问题标题】:Dojo 1.9 and Intern 1.7 - require.on is not defined?Dojo 1.9 和 Intern 1.7 - require.on 没有定义?
【发布时间】:2014-06-30 16:24:42
【问题描述】:

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

我确实有一些测试成功运行但不包含任何小部件。

感谢您的帮助。

【问题讨论】:

    标签: javascript dojo intern


    【解决方案1】:

    您正在运行一个过时的 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'
      }
    })
    

    【讨论】:

      猜你喜欢
      • 2013-09-24
      • 2012-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-14
      • 2013-04-05
      相关资源
      最近更新 更多