【问题标题】:How to be more verbose on tests?如何在测试中更详细?
【发布时间】:2019-11-17 19:49:59
【问题描述】:

我希望为每个测试步骤提供更详细的输出;
关于如何在每个步骤后不添加 console.log 的情况下最好地实现这一点的任何想法?

我尝试重载t 对象,如下所示,但无法让它在输出中工作超过一次。

在 mylib.js 中

exports.init = function(t) {
    t.oTypeText = t.typeText;

    t.typeText = function fn(selector, data, opts) {
        console.log('typing text in '+selector+': '+data);
        return t.oTypeText(selector, data, opts);
    };

    return;
};

在 test.js 中

import { Selector } from 'testcafe';
const mylib = require('./mylib');


fixture("Getting Started")
    .page("https://devexpress.github.io/testcafe/example");


test('My first test', async t => {
    mylib.init(t);
    await t.typeText('#developer-name', 'John Smith')
           .selectText('#developer-name').pressKey('delete')
           .typeText('#developer-name', 'new name')
           .selectText('#developer-name').pressKey('delete')
           .typeText('#developer-name', 'another name');
    await t.click('#submit-button');

});

结果是:

Using locally installed version of TestCafe.
 Running tests in:
 - Firefox 68.0.0 / Mac OS X 10.14.0

 Getting Started
(node:62978) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
typing text in #developer-name: John Smith
 ✓ My first test


 1 passed (4s)

【问题讨论】:

    标签: testing automated-tests e2e-testing testcafe web-testing


    【解决方案1】:

    TestCafe 不支持此功能。我已经在 TestCafe 存储库中为您的用例创建了建议 - https://github.com/DevExpress/testcafe/issues/4001。我们现在可以使用动作覆盖的方式,但理论上它会破坏一些功能。

    【讨论】:

      猜你喜欢
      • 2017-05-12
      • 2015-02-11
      • 2015-04-27
      • 2020-09-28
      • 2020-01-30
      • 2017-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多