【问题标题】:intern serve command is not working after reporters added in intern.js在 intern.js 中添加记者后,intern serve 命令不起作用
【发布时间】:2017-11-23 01:44:46
【问题描述】:

我已全局安装实习生,并且在命令提示符下“实习生服务”命令工作正常。但是,如果我在 intern.js 中添加了记者属性后,如果我运行“实习生服务”命令,那么什么也不会发生,并且命令会卡住,如下所示“正在运行 runner tests...”。

D:\start>实习生服务

运行运行器测试…

这是我的 intern.js 文件

// Learn more about configuring this file at <https://theintern.github.io/intern/#configuration>.
// These default settings work OK for most people. The options that *must* be changed below are the packages, suites,
// excludeInstrumentation, and (if you want functional tests) functionalSuites

define({
    // 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://theintern.github.io/intern/#option-capabilities> for links to the different capabilities options for
    // different services.
    //
    // Note that the `build` capability will be filled in with the current commit ID or build tag from the CI
    // environment automatically
    capabilities: {
        'browserstack.selenium_version': '2.45.0'
    },

    // Browsers to run integration testing against. Options that will be permutated are browserName, version, platform,
    // and platformVersion; any other capabilities options specified for an environment will be copied as-is. Note that
    // browser and platform names, and version number formats, may differ between cloud testing systems.
    environments: [
        { browserName: "chrome", platform: "WINDOWS" }
    ],

    // Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
    maxConcurrency: 2,

    // Name of the tunnel class to use for WebDriver tests.
    // See <https://theintern.github.io/intern/#option-tunnel> for built-in options
    /*tunnel: 'BrowserStackTunnel',*/

    // Configuration options for the module loader; any AMD configuration options supported by the AMD loader in use
    // can be used here.
    // If you want to use a different loader than the default loader, see
    // <https://theintern.github.io/intern/#option-useLoader> for more information.
    loaderOptions: {
        // Packages that should be registered with the loader in each testing environment
        packages: [
            { name: "dojo", location: "node_modules/dojo" },
            { name: "dojox", location: "node_modules/dojox" },
            { name: "dijit", location: "node_modules/dijit" },
            { name: "showcase", location: "dist/src/showcase" },
            { name: "common", location: "dist/src/common" },
            { name: "technical-topics", location: "dist/src/technical-topics" }
        ]
    },

    // Unit test suite(s) to run in each browser
    suites: [ 'tests/**/*.js' ],
    tunnel: 'NullTunnel',

    // Functional test suite(s) to execute against each browser once unit tests are completed
    functionalSuites: [ /* 'myPackage/tests/functional' */ ],

    reporters: [
        { id: 'Runner', filename: 'tests/reporters/Runner/report.html' }
    ],

    // A regular expression matching URLs to files that should not be included in code coverage analysis. Set to `true`
    // to completely disable code coverage.
    excludeInstrumentation: /^(?:tests|node_modules)\//
});

【问题讨论】:

    标签: intern


    【解决方案1】:

    这里有几个问题:

    • 消息“Running runner tests...”仅由 Combined 报告器发出,而不是 Runner 报告器发出。
    • Runner 报告器旨在输出到控制台;给它一个 HTML 文件名只会将文本输出到 HTML 文件(它不会生成 HTML 报告)。
    • 当您运行 intern serve 时,reporter 配置实际上并没有做任何事情,因为 serve 模式下的实习生只是提供文件(而不是运行测试)。

    您的intern.js 文件在tests\ 中吗?实习生假设项目目录如下所示:

    D:\start
      tests\
        intern.js
      node_modules\
        intern\
    

    D:\start 中运行intern serve 时,实习生将在tests\intern.js 中查找其配置文件。

    【讨论】:

    • 是的,我的目录结构和你提到的一样。我的 intern.js 文件位于测试文件夹中。 “intern serve”命令在没有 intern.js 中的记者属性的情况下正常工作。如果我将记者属性添加到 intern.js,那么只有“实习生服务”停止工作。我也尝试过与其他记者合作,但没有工作
    • 你能把整个项目(或者至少是它的一个简化子集)发布到某个地方吗?我很好奇这里发生了什么,因为reporters 属性在“服务”模式下没有做任何事情,即使它做了,你看到的输出也不是来自 Runner 记者。
    • 即使有基本的实习生教程也会重现此问题。我在这里分享了基本设置。如果我从 intern.js 中删除记者属性,那么只有实习生服务有效。存储库:github.com/shuklendu/intern-tutorial
    • intern serve 在所有情况下都有效。问题是,由于您将报告器设置为 JUnit,或将输出重定向到文件,因此您看不到状态消息(通常由 Runner 报告器发出)。在任何情况下,当您运行intern serve 时,更改报告设置是没有用的,因为 Intern 在该模式下没有做任何值得报告的事情(除了提供文件)。要使用自定义报告器设置并在“服务”模式下显示属性输出,请将自定义报告器和 Runner 都包含在报告器列表中。
    猜你喜欢
    • 2020-08-23
    • 2019-08-18
    • 1970-01-01
    • 2018-11-21
    • 2021-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-13
    相关资源
    最近更新 更多