Dojo 1.9和Intern 1.7 - require.on没有定义? [英] Dojo 1.9 and Intern 1.7 - require.on is not defined?

查看:235
本文介绍了Dojo 1.9和Intern 1.7 - require.on没有定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dojo 1.9 Intern 1.7



我在实习中遇到问题,因为它报告说 require.on 没有定义,我的测试套件正在下降。



这只是在尝试定义包含一个窗口小部件的测试时才会发生。它看起来像是小工具包被重新使用,然后它点击一行 require.on(idle,onload)但失败,因为 require.on 未定义。



作为测试,我定义了 require.on ,测试不能掉下来。



所有我想到的是,实习生的dojo版本是在使用实习生需要小部件的时候干扰正常的dojo模块? >

这是我测试的一个缩减版本:

  define([
intern!object,
intern / chai!expect,
dijit / form / Button
],
函数(
registerSuite,
expect,
Button){
registerSuite({
name:Simple test,
failing test for demo:function(){
expect(true).to.be.false;
}
});
});

这是我的配置:

  define({
//仪器代理将侦听的端口
proxyPort:9000,

//一个完全限定的URL实体代理
proxyUrl:'http:// localhost:9000 /',

//所有环境的默认所需功能个别功能可以被任何
/ /在下面的`environments`数组中指定浏览器环境。另请参阅
// https://code.google.com/p/selenium/wiki/DesiredCapabilities以获取标准Selenium功能和
// https ://saucelabs.com/docs/additional-config#desired-对于Sauce Labs功能的功能
//请注意,build功能将使用Travis CI环境中的当前提交ID填写
//自动
功能:{
'selenium-version':'2.40.0'
},

//浏览器运行集成测试。请注意,如果与Sauce
// OnDemand一起使用版本号,则必须是字符串。将被排除的选项是browserName,version,platform和platformVersion;任何为环境指定的
//功能选项将被复制为 -
环境:[
{browserName:'chrome'}
],

//应该在远程WebDriver服务上执行的同时集成测试的最大数量
maxConcurrency:3,

//是否在运行测试之前启动Sauce Connect
useSauceConnect:false,

//远程WebDriver服务的连接信息。如果使用Sauce Labs,请在SAUCE_USERNAME和SAUCE_ACCESS_KEY环境变量中保留用户名和密码
//,除非您确定您将永远不会
//将此配置文件发布到某个地方
webdriver:{
主机:'localhost',
端口:4444
},

//模块加载器的配置选项;可以在这里使用指定的AMD加载器
//支持的任何AMD配置选项
loader:{
//应在每个测试环境中向加载程序注册的包
包:[
{
名称:dojo,
位置:libs / dojo
} {
名称:dijit,
位置: libs / dijit
},{
name:unitTests,
location:test / unit
}
]
},

//在每个浏览器中运行的非功能测试套件
套件:[/ *'myPackage / tests / foo','myPackage / tests / bar'* /
unitTests / exampleTest
],

//功能测试套件运行在每个浏览器一旦非功能测试完成
functionalSuites:[/ * 'myPackage / tests / foo','myPackage / tests / bar'* /
],

//一个正则表达式匹配URL到不应包含在代码覆盖分析中的文件
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'
}
})
/ pre>

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.

解决方案

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:

  1. Upgrade to Dojo 1.9.3 or later. (Recommended.)
  2. 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'
  }
})

这篇关于Dojo 1.9和Intern 1.7 - require.on没有定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆