可以使用dojo / text!在实习生功能测试中? [英] Is it possible to use dojo/text! in an Intern functional test?

查看:331
本文介绍了可以使用dojo / text!在实习生功能测试中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用dojo / text!在实体功能测试中?

Is it possible to use "dojo/text!" in an Intern functional test?

我可以将我的测试页面设置为JSON字符串,但最好我想在文件中外部化字符串,以方便编辑。我刚刚开始使用实习生,所以我只是在尝试可能的,但这里是我测试代码的开始)。

I am able to setup my test page as a JSON string, but ideally I'd like to externalise the string in a file for ease of editing. I'm just getting started with Intern at the moment so I'm just experimenting with what's possible, but here is the start of my test code).

使用了注释的testData变量,但是当我尝试通过dojo / text提供相同的字符串时,当前正在失败!

This works with the commented "testData" variable used, but is currently failing when I try to provide the same String by the dojo/text! statement.

代码:

define([
    'intern!object',
    'intern/chai!assert',
    'dojo/text!./firstTestPageConfig.json',
    'require'
], function (registerSuite, assert, PageConfig, require) {
    registerSuite({
        name: 'firstTest',

        'greeting form': function () {

            var testData = PageConfig;
            // var testData = '{"widgets":[{"name":"alfresco/menus/AlfMenuBar","config":{"widgets":[{"name":"alfresco/menus/AlfMenuBarPopup","config":{"id":"DD1","label":"Drop-Down","iconClass":"alf-configure-icon","widgets":[{"name":"alfresco/menus/AlfMenuGroup","config":{"label":"Group 1","widgets":[{"name":"alfresco/menus/AlfMenuItem","config":{"label":"Item 1","iconClass":"alf-user-icon"}},{"name":"alfresco/menus/AlfMenuItem","config":{"label":"Item 2","iconClass":"alf-password-icon"}}]}},{"name":"alfresco/menus/AlfMenuGroup","config":{"label":"Group 2","widgets":[{"name":"alfresco/menus/AlfMenuItem","config":{"label":"Item 3","iconClass":"alf-help-icon"}}]}}]}}]}}]}';
            var testPage = 'http://localhost:8081/share/page/tp/ws/unittest?testdata=';

            return this.remote
                .get(testPage + testData)
                .waitForElementByCssSelector('.alfresco-core-Page.allWidgetsProcessed', 5000)
                .elementById('DD1')
                    .clickElement()
                    .end()

       }
   });
});

我得到的错误是:

/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/dojo.js:742
                throw new Error('Failed to load module ' + module.mid + ' from ' + url + 
                          ^
Error: Failed to load module dojo/text from /home/dave/ScratchPad/ShareInternTests/dojo/text.js (parent: dojo/text!17!*)
at /home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/dojo.js:742:12
at fs.js:207:20
at Object.oncomplete (fs.js:107:15)

我试过玩加载器/包/地图配置,但没有任何成功,从错误消息中不清楚(至少我)是否找不到要传递到dojo /文本的文件(但是我已经尝试过了)相对路径)或Dojo模块本身?

I've tried playing around with the loader/package/map configuration but without any success. It's not clear (to me at least) from the error message whether or not it can't find the file I'm passing to dojo/text (but I've tried full as well as relative paths) or the Dojo module itself ?

我只想确认我是一个ttempting是可能的,在我花更多的时间与此...但显然任何解决方案或例子将不胜感激!!

I'd just like to confirm that what I'm attempting is possible, before I spend any more time with this... but obviously any solution or example would be greatly appreciated!!

非常感谢,
Dave

Many thanks, Dave

推荐答案

对于您的具体错误:如果要使用,您需要为自己的项目安装Dojo。您正在尝试加载不存在的模块。您还可以尝试使用Intern附带的副本,从 intern / dojo 加载模块,但如果您不明白加载的潜在注意事项,则不建议这个内部库。

To your specific error: You need to install Dojo for your own project if you want to use it. You are trying to load a module that does not exist. You may also try using the copy that comes with Intern, by loading modules from intern/dojo, but this isn’t recommended if you don’t understand the potential caveats of loading this internal library.

要在功能测试中使用 dojo / text ,通常:目前不可能,除非您使用Geezer分支或明确使用Dojo 1加载程序,因为该模块依赖于在Node.js中运行时仅由Dojo 1加载程序公开的功能。完全通用的不同的文本加载器模块可以工作,或者您可以加载 intern / dojo / node!fs 并自己加载文本。这将在未来得到解决。

To using dojo/text in a functional test, generally: This is not currently possible unless you use the Geezer branch or explicitly use the Dojo 1 loader, because that module relies on functionality that is only exposed by the Dojo 1 loader when running in Node.js. A different text loader module that is fully generic would work, or you could load intern/dojo/node!fs and load the text yourself. This will be addressed in the future.

这篇关于可以使用dojo / text!在实习生功能测试中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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