Protractor tests reports using jasmine-reporters
Make sure you have installed jasmine-reporters and the proper path of jasmine-reporters is provided. If it was installed properly then run the below command to see if you get the version of it -
npm list -g jasmine-reporters
If there was a problem installing it, use below command to install it which is compatible with Jasmine 2.x versions -
npm install --save-dev jasmine-reporters@^2.0.0
Update your conf.js file to include proper global scope variable jasmineReporters as mentioned in the package file -
framework: 'jasmine2',
onPrepare: function() {
var jasmineReporters = require('path_of_installed_jasmine-reporters-plugin');
//update proper path, in my case its ('/usr/local/lib/node_modules/jasmine-reporters')
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter(null, true, true, '/test/e2e/JasmineReporter')
);};
Nagarjuna Reddy
Hello, My name is Nagarjuna. I have almost 5 years of experience in UI/Front-end development. I worked for various domains and migrated legacy applications screens to new/latest screens using Angular & Bootstrap. I have hands-on experience in designing responsive screens. I have experience in working with Agile methodology and hands-on experience in using Git, JIRA, Microsoft Azure and basic knowledge in Database Design, Querying and consuming Web Services. Skill : Angular, Angularjs, Javascript, JQuery, HTML, CSS, Bootstrap, Kendo UI, Angular Material, D3.js. Thanks, Nagarjuna
Updated on June 20, 2022Comments
-
Nagarjuna Reddy almost 2 years
I'm trying to export protractor test results to xml files, for that I have installed jasmine-reporters using
npm install -g jasmine-reporters
.Protractor version is
Version 2.1.0
.jasmine-reporters version
2.0.7
This is my protracotr config file:
exports.config = { seleniumAddress: 'http://localhost:4455/wd/hub', capabilities: { 'browserName': 'chrome' }, specs: [ 'student_spec.js' ], onPrepare: function() { require('jasmine-reporters'); jasmine.getEnv().addReporter( new jasmineReporters.JUnitXmlReporter(null, true, true, '/test/e2e/JasmineReporter') ); }, jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 50000 } };
When I run the protractor, I am getting this error
Error: Cannot find module 'jasmine-reporters'
Help me, where I'm doing wrong.
-
Nagarjuna Reddy almost 9 yearsIf I run first command I am getting version like this - /usr/local/lib └── [email protected]
-
giri-sh almost 9 yearsRight, then change the global scope variable to jasmineReporters instead of what you are using and run the test case again as mentioned above.
-
Nagarjuna Reddy almost 9 yearsError: jasmineReporters is not defined
-
giri-sh almost 9 yearsUpdated the answer to change your conf.js file and check if it works. Include framework function and declare jasmineReporters. Hope it works.
-
Nagarjuna Reddy almost 9 yearsI have updated your change but still getting Error: jasmineReporters is not defined
-
giri-sh almost 9 yearsGot an answer for your issue. Its because you are not specifying the path to the jasmine-reporters when you require it. Inside your require() function provide the complete path to the plugin. Updated the same in the answer above. Sorry for the confusion created.
-
Olli about 7 yearsWhen using jasmine 2.2.1, I got the error
JUnitXmlReporter is not a constructor
when using the code above. I had to use the second version of the code found on the accepted answer on this stackoverflow accepted answer to get around the error message:var jasmineReporters = require('jasmine-reporters'); jasmine.getEnv().addReporter( new jasmineReporters.JUnitXmlReporter('xmloutput', true, true) );
.