簡體   English   中英

Dojo 1.9和Intern 1.7-未定義require.on嗎?

[英]Dojo 1.9 and Intern 1.7 - require.on is not defined?

Dojo 1.9Intern 1.7

我對Intern遇到問題,因為它報告require.on並且我的測試套件require.on了。

僅在嘗試定義包含小部件的測試時才會發生這種情況。 它看起來像在require.on("idle", onload)窗口小部件包時碰到了一行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'
  }
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM