Search code examples
jasmineprotractorazure-devopssaucelabsjasmine-reporters

Jasmine custom report is not loading all the tests under Sauce labs tab in VSTS


Automated the e2e tests in CI enabled framework with protractor and jasmine in VSTS. Used the jasmine custom reporter to load the e2e test results under sauce labs tab in VSTS build definition. But, it is not loading all the tests. It is displaying only the last e2e test ran in the build. Console log is getting printed for all the e2e tests. Please see the code below.

let sauceLabsReporter: jasmine.CustomReporter = {
specDone: (result: jasmine.CustomReporterResult): void => {
    Util.log('*** sauceLabsReporter: result.fullName:', result.fullName);
    Util.log('*** sauceLabsReporter: result.status:', result.status);
    Util.log('*** sauceLabsReporter: result.testCaseId:', result.testCaseId);

    if (result.testCaseId) {
        result.fullName = `(Testcase ID: ${result.testCaseId}): ${result.fullName}`;
        Util.log('*** sauceLabsReporter: UPDATED result.fullName:', result.fullName);
    }

    Util.updateSauceLabsJobTitle(result.fullName);

    if (result.status) {
        Util.updateSauceLabsTestState(result.status);
    }
}
};

export function updateSauceLabsJobTitle(title: string): promise.Promise<void> {
let fullTitle: string = `${title} | (${getHostname()})`;

return browser.executeScript(`sauce:job-name=${fullTitle}`)
    .then(() => browser.getSession())
    .then((session: Session) => {
        if (isThisVSTSBuildAgent()) {
            //The VSTS Sauce Labs add-on gets information by parsing the console log.
            //tslint:disable-next-line:no-console
            console.log(`SauceOnDemandSessionID=${session.getId()} job-name=${fullTitle}`);
        }
    });
 }

export function updateSauceLabsTestState(state: string): promise.Promise<{}> {

  return browser.executeScript(`sauce:job-result=${state}`);
 }

Solution

  • I work on the same project as Padma. It had to do with restartBrowserBetweenTests being set to false which conflates all tests into a single job. After setting it to true, each test became its own job.