Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

protractor/jasmine get test meta

I'm trying to fetch test meta during runtime, especially test name/description. I'm using protractor version 5.3.2 and jasmine of version 2.8.8

Past threads on stackoverflow relied in jasmine to perform this task, but I failed following the instructions/

Any suggestions?

like image 290
Roi Shabtai Avatar asked Nov 23 '25 00:11

Roi Shabtai


1 Answers

Yes you can get this from jasmine, it's fairly easy to create a basic reporter and then you can expand on it from there. Here are Jasmine docs on custom reporter

Here's a basic sample:

// specReport.js
class SpecReport {
    // these functions are automatically provided from jasmine, nothing else required
    jasmineStarted(result) {
        console.log(result);
    };

    jasmineDone(result) {
        console.log(result);
    };

    suiteStarted(result) {
        console.log(result);
    };

    suiteDone(result) {
        console.log(result);
    };

    specStarted(result) {
        console.log(result);
    };

    specDone(result) {
        console.log(result);
    };
};

module.exports = SpecReport;

And then pull this file into your config and instantiate it during onPrepare:

// conf.js
const SpecReport = require('./specReport');
exports.config = {
    framework: 'jasmine2',
    ... other stuff...

    onPrepare: function() {
        jasmine.getEnv().addReporter(new SpecReport());
    }
}

This will start printing basic properties of the test during runtime which includes suite descriptions, test names etc.

like image 114
Gunderson Avatar answered Nov 24 '25 22:11

Gunderson



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!