-
Notifications
You must be signed in to change notification settings - Fork 3.1k
-
Star 46.4k
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
Incorrect JSON coding format after mochawesome-merge #5111
Comments
AliceShi789654
commented
Sep 10, 2019
•
edited by jennifer-shehane
edited by jennifer-shehane
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.
|
maximumsnow
commented
Sep 11, 2019
I believe I'm seeing the same issue. I added comments to issue #5103 I'm not going to duplicate them here. |
HareemManzoor
commented
Sep 15, 2019
Getting same issue. |
HareemManzoor
commented
Oct 1, 2019
•
edited by jennifer-shehane
edited by jennifer-shehane
@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
commented
Oct 23, 2019
facing same issue, anyone has any solution??
|
HareemManzoor
commented
Oct 25, 2019
@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 :) |
mylearning1005
commented
Apr 16, 2020
•
edited by jennifer-shehane
edited by jennifer-shehane
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
}
} |
mstephano
commented
May 12, 2020
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) |
automationJatinder
commented
Jul 7, 2020
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? |
gaurav05153
commented
Jul 23, 2020
|
gaurav05153
commented
Jul 23, 2020
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. |
gaurav05153
commented
Jul 23, 2020
•
edited by jennifer-shehane
edited by jennifer-shehane
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. |
nids2307
commented
Sep 9, 2020
•
edited
edited
When I try to install cypress-mochawesome-reporter, I see the following error: |
hnnesv
commented
Aug 16, 2021
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 |
mflynn001
commented
Mar 22, 2022
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: |
mustaf19
commented
May 12, 2023
Its an issue since ancient times.. I still have this issue.. |
nagash77
commented
May 12, 2023
@mustaf19 did the solution @mflynn001 shared work for you? |
isacraraujo
commented
May 23, 2023
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: