1

I am writing the output of my TestCafe to file. I was wondering if it can be a dynamic path like a screenshot path.

I tried using something like the values listed here, but I think this is only for screenshots and videos.

https://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/screenshots-and-videos.html#path-pattern-placeholders

Here is what works, but is just not dynamic:

testcafe chrome test.testcafe -r json:report.json

Here is what I would like to do:

testcafe chrome test.testcafe -r json:T:\Logs\ -p ${DATE}/${TIME}/${FIXTURE}/${TEST}/${FILE_INDEX}.json

EDIT 1: Should have said this, but I am using TestCafe Studio. I can use the built-in Function action, but I'm stuck with the limited functionality of Studio.

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Will York
  • 13
  • 4

2 Answers2

2

Currently, TestCafe Studio does not allow customizing a report name. We will consider your suggestion for our future releases.

As a workaround, I recommend you take a look at the Export the Report functionality

Alex Kamaev
  • 6,198
  • 1
  • 14
  • 29
1

I suggest you use the programming interface to customize your reporter output:

run.js:

const createTestCafe = require('testcafe');
let testcafe         = null;

createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe     = tc;
        const runner = testcafe.createRunner();

        const config = { key1: 'value1', key2: 'value2' }; // you can specify it as a date, etc.

        return runner
            .src(['d:/***/test.js'])
            .browsers(['chrome'])
            .reporter('xunit', `reports/${config.key1}/out-${config.key2}.xml`)
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });

Command:

node run.js
Vladimir A.
  • 2,202
  • 2
  • 10
  • 28
  • Thanks for the suggestion. I'm however looking for a solution to add as an argument. I'm using TestCafe Studio and can't do what you suggested however. I am trying to use the [Configuration](https://devexpress.github.io/testcafe/documentation/using-testcafe/configuration-file.html) file they suggest to use – Will York Oct 08 '19 at 14:29