gpt4 book ai didi

testing - 如何在测试中更加冗长?

转载 作者:行者123 更新时间:2023-12-04 15:43:14 24 4
gpt4 key购买 nike

我希望每个测试步骤都有更详细的输出;
关于如何在不在每个步骤后添加 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)

最佳答案

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

关于testing - 如何在测试中更加冗长?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56932508/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com