Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Testrail - protractor integration


#1

I am trying to run below .js file but its throwing me error:

resultLeaker = {
    suiteStarted: function (result) { jasmine.results = { suite: result }; },
    specStarted: function (result) { jasmine.results.spec = result; }
};
jasmine.getEnv().addReporter(resultLeaker);

describe('TestRail Reporter', function () {
    var TestRail = require("testrail-promise");
    var jasmine = require("jasmine-testrail-reporter");
    var jasmine = require("jasmine-spec-reporter");

    var tr = new TestRail("https://testims.testrail.io/index.php?/api/v2/", "vgupta@360logica.com", "#8954Vg#");

    it('Passing', function() {
        expect(true).toBeTruthy();
    });

    it('failing', function() {
        expect(false).toBeTruthy();
    });

    afterEach(function (done) {
        reportToTestRail(this).finally(function () {
            done();
        });
    });

    var reportToTestRail = function (test) {
        var obj = {
            "project_name":"Test",
            "plan_name":"TEST",
            "section_name":"TEST",
            "title": jasmine.results.spec.fullName,
            "status": (jasmine.results.spec.failedExpectations.length === 0 ? "passed" : "failed")

        };
        return tr.ifNeededCreateThenAddResultForCase(obj);
    };
});

but while running it , its giving me error below:

  1. TestRail Reporter Passing
    Message:
    Failed: Cannot read property ‘spec’ of undefined
    Stack:
    TypeError: Cannot read property ‘spec’ of undefined
    at reportToTestRail (C:\Users\user\source\repos\Protractor\TestJSProtr
    actor\TestRail.js:33:38)
    at UserContext. (C:\Users\user\source\repos\Protractor\Test
    JSProtractor\TestRail.js:23:9)
    at C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modu
    les\jasminewd2\index.js:108:15
    at new ManagedPromise (C:\Users\user\AppData\Roaming\npm\node_modules
    protractor\node_modules\selenium-webdriver\lib\promise.js:1077:7)
    at ControlFlow.promise (C:\Users\vgupta\AppData\Roaming\npm\node_modules
    \protractor\node_modules\selenium-webdriver\lib\promise.js:2505:12)
    at schedulerExecute (C:\Users\user\AppData\Roaming\npm\node_modules\pr
    otractor\node_modules\jasminewd2\index.js:95:18)
    at TaskQueue.execute_ (C:\Users\user\AppData\Roaming\npm\node_modules
    protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
    at TaskQueue.executeNext_ (C:\Users\user\AppData\Roaming\npm\node_modu
    les\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
    at asyncRun (C:\Users\user\AppData\Roaming\npm\node_modules\protractor
    \node_modules\selenium-webdriver\lib\promise.js:2974:25)
    at C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modu
    les\selenium-webdriver\lib\promise.js:668:7
    at
    at process.tickCallback (internal/process/next_tick.js:188:7)
    From: Task: Run afterEach in control flow
    at UserContext. (C:\Users\user\AppData\Roaming\npm\node_mod
    ules\protractor\node_modules\jasminewd2\index.js:94:19)
    at C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modu
    les\jasminewd2\index.js:64:48
    at ControlFlow.emit (C:\Users\user\AppData\Roaming\npm\node_modules\pr
    otractor\node_modules\selenium-webdriver\lib\events.js:62:21)
    at ControlFlow.shutdown
    (C:\Users\user\AppData\Roaming\npm\node_modul
    es\protractor\node_modules\selenium-webdriver\lib\promise.js:2674:10)
    at shutdownTask_.MicroTask (C:\Users\user\AppData\Roaming\npm\node_mod
    ules\protractor\node_modules\selenium-webdriver\lib\promise.js:2599:53)
    at MicroTask.asyncRun (C:\Users\user\AppData\Roaming\npm\node_modules
    protractor\node_modules\selenium-webdriver\lib\promise.js:2728:9)
    at C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modu
    les\selenium-webdriver\lib\promise.js:668:7
    at
    at process._tickCallback (internal/process/next_tick.js:188:7)
    From asynchronous test:
    Error
    at Suite. (C:\Users\user\source\repos\Protractor\TestJSProt
    ractor\TestRail.js:22:5)
    at Object. (C:\Users\user\source\repos\Protractor\TestJSPro
    tractor\TestRail.js:7:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions…js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at C:\Users\user\AppData\Roaming\npm\node_modules\protractor\node_modu
    les\jasmine\lib\jasmine.js:93:5
    at Array.forEach ()
    at Jasmine.loadSpecs (C:\Users\user\AppData\Roaming\npm\node_modules\p
    rotractor\node_modules\jasmine\lib\jasmine.js:92:18)

could anyone please help me in resolving the error