Leadfoot被安装为Intern框架(./node_modules/intern/node_modules/leadfoot)的一部分。但是,当我尝试使用它作为文档(https://theintern.github.io/leadfoot/pollUntil.html)时:

define([
    'intern!object',
    'intern/chai!assert',
    'require'
], function (registerSuite, assert, require) {
    var url = '../../index.html';
    var Command = require('leadfoot/Command');
    var pollUntil = require('leadfoot/helpers/pollUntil');

    registerSuite({
        name: 'Todo (functional)',

        'submit form': function () {
            return this.remote.get(require.toUrl(url))
                .findById('new-todo').then(function (val) {}, function(err) {
                     console.log(err);
                }).click();
        }
    });
}


我收到以下错误:

$ intern-runner config=tests/example_intern
Listening on 0.0.0.0:9000
Starting tunnel...
Error: Attempt to require unloaded module leadfoot/Command
  at contextRequire  <node_modules/intern/node_modules/dojo/dojo.js:255:12>
  at module.require.result  <node_modules/intern/node_modules/dojo/dojo.js:284:13>
  at </home/bogdanbiv/WebstormProjects/life-tracker3/dojo-example/tests/functional/Todo.js:9:16>
  at execModule  <node_modules/intern/node_modules/dojo/dojo.js:515:54>
  at <node_modules/intern/node_modules/dojo/dojo.js:504:12>
  at Array.map  <native>
  at execModule  <node_modules/intern/node_modules/dojo/dojo.js:499:17>
  at <node_modules/intern/node_modules/dojo/dojo.js:582:7>
  at guardCheckComplete  <node_modules/intern/node_modules/dojo/dojo.js:566:4>
  at checkComplete  <node_modules/intern/node_modules/dojo/dojo.js:574:27>


有人可以解释在功能测试中如何正确使用Leadfoot吗?

插入建议的更改:

$ intern-runner config=dojo-example/tests/intern
Listening on 0.0.0.0:9000
Starting tunnel...
Error: Failed to load module leadfoot/helpers/pollUntil from /home/bogdanbiv/WebstormProjects/life-tracker3/leadfoot/helpers/pollUntil.js (parent: dojo-example/tests/functional/Todo)
  at <node_modules/intern/node_modules/dojo/dojo.js:757:12>
  at <fs.js:207:20>


在Object.oncomplete

最佳答案

尝试将Leadfoot模块ID放在define数组中,而不是在requiring中。

define([
    'intern!object',
    'intern/chai!assert',
    'require',
    'intern/dojo/node!leadfoot/Command',
    'intern/dojo/node!leadfoot/helpers/pollUntil'
], function (registerSuite, assert, require, Command, pollUntil) {

09-18 03:36