Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to be more verbose on tests?

I wanted to have more verbose output for each test step;
Any ideas on how could I best achieve this without adding console.log after each step ?

I tried to overload the t object as shown below but can't get to have it work more than one time in the output.

in 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;
};

in 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');

});

result is:

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)
like image 495
vik Avatar asked Dec 15 '25 14:12

vik


1 Answers

TestCafe doesn't support this feature out of box. I've created suggestion for you use case - https://github.com/DevExpress/testcafe/issues/4001 in the TestCafe repository. We can use the way with action overriding right now, but theoretically it can broke some functionality.

like image 197
mlosev Avatar answered Dec 19 '25 07:12

mlosev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!