-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect JSON coding format after mochawesome-merge #5111
Comments
I have updated the sample code and now it runs cypress:run successfully: https://github.com/AliceShi789654/Atest. But mochawesome-report-generator was still failed. Thanks.
|
I believe I'm seeing the same issue. I added comments to issue #5103 I'm not going to duplicate them here. |
Getting same issue. |
@maximumsnow Add following lines of code to your package.json file under scripts tag. "scripts": {
"delete-mochawesome-folder":"rm -f mochawesome-report/*.json",
"e2e_mochawesome": "yarn cypress run --spec cypress/integration/Tests/*.js",
"merge-json":"npx mochawesome-merge --reportDir mochawesome-report > mochawesome1.json",
"html-generator": " npx mochawesome-report-generator mochawesome1.json"
}
Now execute above commands in sequence and here you go ;) |
@prudhvidandamudi please make sure that you are removing all the previous json reports. Also can you please the folder structure? Just want to make sure that you have placed your json report in correct folder. Thanks in advance :) |
I am getting the following error : Can some one please help
package.json "devDependencies": {
"cypress": "^4.3.0",
"mocha": "5.2.0",
"mochawesome": "4.1.0",
"mochawesome-merge": "4.0.3",
"mochawesome-report-generator": "4.1.0"
} cypress.json {
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/results",
"overwrite": false,
"html": false,
"json": true
}
} |
I had same issue with Unexpected token while trying to create the report on Windows 10. Here is my solution on another issue: Antontelesh/mochawesome-merge#6 (comment) |
I am still facing this problem (Unexpected token � in JSON at position 0) when using marge command to create HTML file. Does anyone has a solution for this? |
|
I tried your approach but "html-generator" step didn't work for me. Still I am on same issue where different report jsons are created but generation of a combined HTML report didn't work for me. |
Guys, I found the best solution of this problem. With this solution, we don't have to do much with the configurations or setup. Solution is the "cypress-mochawesome-reporter". It will handle all the corner cases which we were facing with generating mochawesome report, then merge and then marge to consolidate all the jsons.
It will create a folder results/html where you can find your consolidated report named "mochasome.html" Just try it, you will have a smile while looking into the consolidate report with all ease. Hope, it will help you. |
When I try to install cypress-mochawesome-reporter, I see the following error: |
In case this is helpful for anyone, I ran into the same issue as the original summary and looks like the issue was related to how Powershell encodes the output to file: mochawesome-merge .\report\*.json > .\merged.json # doesn't work For me the fix was to instead use something as follows to explicitly use ASCII: mochawesome-merge .\report\*.json | out-file -encoding ascii .\merged.json |
If anyone is still struggling with this issue, the solution can be found here: https://www.npmjs.com/package/mochawesome-merge you need to use the following syntax now to avoid the JSON coding format issue: the below syntax is technically legacy, but I still seem to run into the issue mentioned here when i use it, so do not use this: |
Its an issue since ancient times.. I still have this issue.. |
@mustaf19 did the solution @mflynn001 shared work for you? |
Amazing! I'm using Mochawesome in Cypress, and this simple detail solved my problem! |
Current behavior:
about : #5103
Steps to reproduce: (app code and test code)
Although there were errors in the log , but the result is generated. You can get two
.json
files in 'mochawesome-report '.Then merge two
.json
into one to generate in the root directory.Finally, run the command to generate report failed :
I found that the JSON encoding format after merge was incorrect, and I didn't want to change it manually. I needed to integrate it into automated deployment and test scripts.
The text was updated successfully, but these errors were encountered: