belan97 / mochawesome-screenshots Goto Github PK
View Code? Open in Web Editor NEWThis is a fork of Mochawesome(MochawesomePlusPlus) reporter with added screenshots functionality.
This is a fork of Mochawesome(MochawesomePlusPlus) reporter with added screenshots functionality.
Hi,
I am not able to save a screenshot using this mochawesome-sreenshot tool. below is the error I am getting-
Error: Unable to save screenshot
ReferenceError: path is not defined
Though the html report is created successfully but the failing screenshot is not there. Could you please check this and correct it.
conf.js file-
framework: 'mocha',
mochaOpts: {
grep: util.getGrep(),
reporter: 'mochawesome-screenshots',
reporterOptions: {
reportTitle: util.getTitle(),
inlineAssets: true
},
timeout: 60000 /* --mochaOpts.timeout*/
}
Thanks & Regards,
Hitesh Gupta
I'm using mocha for my test case. I am getting report using mochawesome as well with mochawesome screenshot, How do I attach screenshot with my failed test case?
Hi,
Here are my nightwatch config options for mocha
"test_runner" : {
"type" : "mocha",
"options" : {
"ui" : "bdd",
"reporter": "mochawesome-screenshots",
"reporterOptions": {
"takePassedScreenshot": false,
"clearOldScreenshots": true,
"jsonReport": false,
"multiReport": false,
"timeout": 600000
}
}
}
I am not getting screenshots for the failed test cases, but HTML report is coming properly.
Its even adding screenshot file name in HTML but the screenshots folder is empty.
When I looked into reportGenerator.js I see that browser object is undefined in method saveScreenshotToFile.
Since browser object is undefined its not able to capture screenshots.
Can you please help me on how to solve this problem ?
Hi,
Great report. I'd like to add a feature request. I pulled your code down and added a couple of changes. Unlock jasmine framework, mocha only allows one expect() per test. So I needed a way to have multiple screenshots per single failure.
I updated the setScreenshot() function to keep an array of screenshots plus an optional title for each one. So far its been working well. Its still backwards compatible to the way it currently is too. I wasn't able to create a pull request but here's what I changed. Thoughts?
lib/logReport.js
var setScreenshot = function setScreenshot() {
if ((!arguments[0].test && !arguments[0].ctx) || !arguments[1] || typeof arguments[1] !== 'string') {
console.log('\n[' + chalk.gray('mochawesome') + '] Error: Invalid arguments.');
return;
}
if (!arguments[2]) {
arguments[2] = '';
}
var test = arguments[0].test ? arguments[0].test: arguments[0];
if (!test.customScrFileName) {
test.customScrFileName = [ [ arguments[1], arguments[2] ] ];
} else {
test.customScrFileName.push([ arguments[1], arguments[2] ]);
}
};
lib/mochawesome.js
function cleanTest (test) {
var err = test.err ? _.pick( test.err, ['name', 'message', 'expected', 'actual', 'stack', 'scr'] ) : test.err,
scr = '';
if (test.customScrFileName) {
test.customScrFileName.forEach(function (fileName) {
if(fileName[1]) {
scr += '<p class="test-error-message">' + fileName[1] + '</p>';
}
scr += '<img src="./screenshots/' + fileName[0] + '">';
});
} else {
scr = '<img src="./screenshots/' + test.scrFileName + '">';
}
I am seeing an issue where my reports don't show the screenshots. When I dug in, it looks like the screenshot names are so long, they are getting truncated by OS X but the report is looking for the full filename.
For example, the source is loading: ./screenshots/48123_create_a_collection_as_a_logged_in_agent_create_collection_ui_tests_asserts_that_invalid_character_values_are_rejected_by_the_ui.png
But the screenshots folder has this file: 48123__regression___agent___boards___collections_create_a_collection_as_a_logged_in_agent_create_collection_ui_tests_asserts_that_inva.png
Also note how the filenames have double underscores around the mocha tags, but the HTML doesn't expect them.
Can we have an option to just have unique numbers as the names of the screenshots?
can you please include a feature to view/hide Passed, failed, pending or skipped tests in reports.
I'm trying to use this reporter with protractor, Mocha and Yadda, running Gherkin features.
Mochawesome works excellently with this setup, but the screenshot reporter does not, as when creating screenshots it creates the filename by combining the feature title, the scenario title and the step text, creating an enormous filename that is not accessible.
i.e. If I had the Feature
Feature: I want to test a certain aspect of my web application
Scenario: When I do some stuff then some other stuff happen that is good
Given I am using my app
When I click some buttons or something in the prescribed manner
Then stuff should happen
if the test fails on the 'When' step of this feature then the generated screenshot name will be:
I_want_to_test_a_certain_aspect_of_my_web_application_When_I_do_some_stuff_then_some_other_stuff_happen_that_is_good_When_I_click_some_buttons_or_something_in_the_prescribed_manner.png
Is there any way to shorten these names, or create custom names? As it stands I can't use this reporter.
When we were using Jasmine framework, a screenshot reporter we used had the option to capture the current HTML of the page. This was useful to be able to view the state of the app in a browser for debugging. We would be able to see attributes and formatting.
Could you add this option and add it to the report as [Open HTML] so that it opens the HTML in a new browser tab/window?
Thanks
Hello,
First, thanks for your work !
I just check your project, and i've some issues with screenshots display.
Context:
Issues:
<p class="test-screenshot"><button class="btn btn-link btn-sm toggle-btn toggle-stack collapsed" data-toggle="collapse" data-target="#7c7a16b9-c156-447b-9afc-aa7db71f2b92 > .test-scr.collapse">Screenshot </button> </p>
I've test with firefox, chrome, chormium, same issue.
Thanks
My project requires that I display a screenshot after every test. It'd be nice if there was a way to set that in the parameters. I think if Show Screenshots was displayed before Show Stack, you'd be able to display it for each test regardless of pass/fail
Hi,
Here are my cypress config options for mocha
"reporter": "mochawesome-screenshots",
"reporterOptions": {
"reportTitle": "Report",
"reportPageTitle": "AutomationReport",
"takePassedScreenshot": false,
"clearOldScreenshots": true,
"uniqueScreenshotNames": true
}
I am not getting screenshots for the failed test cases, but HTML report is coming properly.
Its even adding screenshot file name in HTML but the screenshots folder is empty.
Can you please help me on how to solve this problem ?
Lorreport setScreenshot put images to folder screenshots but only one is html report file. How view all images in report html?
I am using puppeteer and have set the page variable as a global variable via a global.js file and
page = null;
When running a test I no screenshot image saving to the screenshot folder
gulp build
crashing in config line#51, had to comment out the line below to make it work.
config.multiReport = _getOption('multiReport', options);
Please add
var path = require('path');
in mochawesome-screenshots/lib/mochawesome.js
Currently when i run any mocha script successfully, i am only able to view only the "it" hook of the mocha.
Is there any provision/parameter which needs to be passed in .mocharc.js file to make the "before" and "after" hooks also visible in the report, irrespective of those hooks passing or failing?
Secondly, using, require("mochawesome-screenshots/logReport");
I am able to send log to "it" hook, when i am trying to send any custom log for "before" or "after", it does not get displayed in the report.
Hola!
I'm working on different browsers, and would prefer that mochawesome would generate one report with the results for the different browsers instead of creating the report for each multiCapability. The report keeps overwriting itself. Maybe a flag such as --combineBrowsers?
When running with multiple threads the last one to close seems to always hang. This issue does not happen with mochawesome just with mochawesome-screenshots. To try it out set shardTestFiles: parallel
in capabilities in the protractor conf file
I don't think mocha waits for the on fail event to complete before moving on to the next test???
Hi ,
how do i get step wise report using mochawesome-screenshots.
For Ex: if i have 5 steps in my test method nad it failed at step 5 , then for step 1-4 it should give passed and for step 5 it should give me failed with reason or exception.
Is there any way to use logger.log at global level which logs report for each step .?
i see the source code ,now it can't show the passed screenshot in the html, also i have already set the "takePassedScreenshot": true
Context: (CodeceptJS with Protractor execution driver)
Issue:
P.S. There is no issue when I run test by Protractor without CodeceptJS.
mochawesome-screenshots/lib/logReport.js
Line 31 in d5ef5f4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.