Search code examples
testingautomated-testsreporttestcafetestrail

Html-testrail report in testcafe not coming correct


I downloaded testcafe-reporter-html-testrail and using this in my testcafe project. If I am giving a custom name to the report then it's failing to save properly, i.e report is not complete, its almost blank with few lines...However, if I am NOT giving the custom name then the report is saving in the format Report_TIMESTAMP.html (e.g.: Report_16_5_2018_14_46_46.html) What am I doing wrong here?

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

createTestCafe()
.then(tc => {
    testcafe     = tc;
    const runner = testcafe.createRunner();

    let id;
    const deadlinePromise = new Promise((resolve,reject) => {
        id=setTimeout(() => {
       clearTimeout(id);
       reject('testcase couldnt meet the actual preferred time');
        },215000)
     });

const runPromise=runner
    .src(test1.ts)  
    .browsers('chrome:headless')
     // what am I doing wrong in the below step? the report is not saving properly
    .reporter('html-testrail', 'Reports/report1.html')        
    .run({skipJsErrors:true})             


race =Promise.race([runPromise,deadlinePromise])
race.then((res) => console.log(res))      

})

       .catch(failedCount => {
           console.log('Tests1 failed: ' + failedCount);
            testcafe.close();
        })

Solution

  • The html-testrail reporter ignores the output option and uses HTML_REPORT_PATH and HTML_REPORT_NAME environment variables instead. You can use process.env to modify environment variables and save your report in the desired location:

    process.env.HTML_REPORT_PATH = path.resolve('Reports');
    process.env.HTML_REPORT_NAME = 'report1.html';