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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With