package.json:
script {"cypress-run": "cypress run"}
cypress.json:
{
"reporter": "mochawesome",
"reporterOptions": {
"overwrite": false,
"html": false,
"json": true
}
}
run the following command:
PS C:\1_Code\Atest> npm install
PS C:\1_Code\Atest> npm run cypress:run
-- Report JSON saved to .\mochawesome-report, mochawesome.json, mochawesome_001.json, mochawesome_002.json
PS C:\1_Code\Atest> npx mochawesome-merge > mochawesome.json
-- merged JSON saved to .\mochawesome.json
PS C:\1_Code\Atest> npx mochawesome-report-generator mochawesome.json
npx: installed 50 in 6.289s
โ Some files could not be processed:
mochawesome.json
Unexpected token ๏ฟฝ in JSON at position 0
mochawesome.json encoding: Unincode
how to resolved it?
"cypress": "^3.4.1",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.23.1",
"mocha-multi-reporters": "^1.1.7",
"mochawesome": "^4.1.0",
"mochawesome-merge": "^2.0.1",
"mochawesome-report-generator": "^4.0.1",
I was unable to recreate the issue as described. My log on npm run cypress:run
Maybe make sure you don't have any conflicting modules globally installed.
npm run cypress:run
> @ cypress:run /Users/jennifer/Dev/Atest
> cypress run
====================================================================================================
(Run Starting)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cypress: 3.4.1 โ
โ Browser: Electron 61 (headless) โ
โ Specs: 2 found (demo_baidu.ts, sample-spec.ts) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Running: demo_baidu.ts... (1 of 2)
My first test case for cypress
1) visit baidu home page and search for testerhome:
0 passing (6s)
1 failing
1) My first test case for cypress
visit baidu home page and search for testerhome::
Uncaught Error: Script error.
Cypress detected that an uncaught error was thrown from a cross origin script.
We cannot provide you the stack trace, line number, or file where this error occurred.
Check your Developer Tools Console for the actual error - it should be printed there.
It's possible to enable debugging these scripts by adding the 'crossorigin' attribute and setting a CORS header.
https://on.cypress.io/cross-origin-script-error
This error originated from your application code, not from Cypress.
When Cypress detects uncaught errors originating from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the 'uncaught:exception' event.
https://on.cypress.io/uncaught-exception-from-application
at createErrFromMsg (http://www.baidu.com/__cypress/runner/cypress_runner.js:76831:14)
at Object.createUncaughtException (http://www.baidu.com/__cypress/runner/cypress_runner.js:76836:13)
at Object.onUncaughtException (http://www.baidu.com/__cypress/runner/cypress_runner.js:80407:20)
at onError (http://www.baidu.com/__cypress/runner/cypress_runner.js:79633:39)
[mochawesome] Report JSON saved to /Users/jennifer/Dev/Atest/mochawesome-report/mochawesome.json
(Results)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Tests: 1 โ
โ Passing: 0 โ
โ Failing: 1 โ
โ Pending: 0 โ
โ Skipped: 0 โ
โ Screenshots: 1 โ
โ Video: true โ
โ Duration: 5 seconds โ
โ Spec Ran: demo_baidu.ts โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
(Screenshots)
- /Users/jennifer/Dev/Atest/cypress/screenshots/demo_baidu.ts/My first test case for cypress -- visit baidu home page and search for testerhome (failed).png (1280x720)
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: /Users/jennifer/Dev/Atest/cypress/videos/demo_baidu.ts.mp4 (0 seconds)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Running: sample-spec.ts... (2 of 2)
My first test case for cypress
โ Does not match!
1 passing (47ms)
[mochawesome] Report JSON saved to /Users/jennifer/Dev/Atest/mochawesome-report/mochawesome_001.json
(Results)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Tests: 1 โ
โ Passing: 1 โ
โ Failing: 0 โ
โ Pending: 0 โ
โ Skipped: 0 โ
โ Screenshots: 0 โ
โ Video: true โ
โ Duration: 0 seconds โ
โ Spec Ran: sample-spec.ts โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: /Users/jennifer/Dev/Atest/cypress/videos/sample-spec.ts.mp4 (0 seconds)
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ demo_baidu.ts 00:05 1 - 1 - - โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ sample-spec.ts 46ms 1 1 - - - โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1 of 2 failed (50%) 00:06 2 1 1 - -
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ cypress:run: `cypress run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ cypress:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jennifer/.npm/_logs/2019-09-09T14_22_06_614Z-debug.log
Unfortunately we have to close this issue as there is not enough information to reproduce the problem. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.
Please comment in this issue with a reproducible example and we will reopen the issue. ๐
I'm looking at setting up a POC with Cypress and I'm going through the steps outlined on https://docs.cypress.io/guides/tooling/reporters.html#Multiple-reporters-examples
I believe I am having the same issue. I'm merging the reports for all the example spec files that cypress loads so they are all passing (if that makes any difference).
Running: npx mochawesome-merge --reportDir cypress/results > mochawesome.json
creates the mochawesome.json but it appears to be malformed because when I run the next command: npx mochawesome-report-generator mochawesome.json
I get "Unexpected token ๏ฟฝ in JSON at position 0"
Windows v10.0.14393
Nodejs v10.16.3
"cypress": "^3.4.1",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.23.1",
"mocha-multi-reporters": "^1.1.7",
"mochawesome": "^4.1.0",
"mochawesome-merge": "^2.0.1",
"mochawesome-report-generator": "^4.0.1"
An update... I can open the "merged" json file in VSCode and copy the contents to a new json file and the mochawesome-report-generator processes it without error. So there is something about that "merged" file that VSCode didn't load into the editor to be copied to the new file is causing the error.
duplication steps:
npm init -y
npm install cypress [email protected] mocha-junit-reporter mocha-multi-reporters mochawesome mochawesome-merge mochawesome-report-generator --save-dev
./node_modules/.bin/cypress open
{
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/results",
"overwrite": false,
"html": false,
"json": true
}
}
"scripts": {
"cy:run": "cypress run",
"delete:reports": "del /F/Q/S cypress\\results\\*.*",
"prereport": "npm run delete:reports",
"report": "cypress run"
}
node run report
npx mochawesome-merge --reportDir cypress/results > merged.json
npx mochawesome-report-generator merged.json
Result:
โ Some files could not be processed:
merged.json
Unexpected token ๏ฟฝ in JSON at position 0
I have the same issue
I'm looking at setting up a POC with Cypress and I'm going through the steps outlined on https://docs.cypress.io/guides/tooling/reporters.html#Multiple-reporters-examples
I believe I am having the same issue. I'm merging the reports for all the example spec files that cypress loads so they are all passing (if that makes any difference).
Running:
npx mochawesome-merge --reportDir cypress/results > mochawesome.json
creates the mochawesome.json but it appears to be malformed because when I run the next command:npx mochawesome-report-generator mochawesome.json
I get "Unexpected token ๏ฟฝ in JSON at position 0"Windows v10.0.14393
Nodejs v10.16.3"cypress": "^3.4.1", "mocha": "^5.2.0", "mocha-junit-reporter": "^1.23.1", "mocha-multi-reporters": "^1.1.7", "mochawesome": "^4.1.0", "mochawesome-merge": "^2.0.1", "mochawesome-report-generator": "^4.0.1"
I have the same issue. I'm not sure why the Json file format result of the merge is UTF-16. But if I create a new one and copy/paste and save in a new Json, marge works ok and the HTML file is created.
@jennifer-shehane maybe we can reopen this issue or create a new one.
This issue is also reported as #5111 which is still open.
Had the same issue. But got it solved after removing space.
npx mochawesome-merge --reportDir cypress/result**s > m**ochawesome.json
npx mochawesome-merge --reportDir cypress/result**s>m**ochawesome.json
@thinkx-23 Thanks so much for the comment! i'll try this week and i'll give you some feedback.
update: It's working!
Had the same issue. But got it solved after removing space.
npx mochawesome-merge --reportDir cypress/results > mochawesome.json
npx mochawesome-merge --reportDir cypress/results>mochawesome.json
Thank you so much . It worked !!!
Removing spaces did not work for me on Windows 10. Here is my solution on another issue:
https://github.com/Antontelesh/mochawesome-merge/issues/6#issuecomment-627496076
> mochawesome-merge cypress/reports/*.json > cypress/reports/output.json
ERROR: Failed to merge reports
SyntaxError: cypress/reports/output.json: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at C:\Mayank\Cypress_Code\node_modules\jsonfile\index.js:33:18
at C:\Mayank\Cypress_Code\node_modules\graceful-fs\graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
Anyone have any solutions for the above issue in Windows 10
Removing spaces did not work for me on Windows 10. Here is my solution on another issue:
Antontelesh/mochawesome-merge#6 (comment)
I used the json online editor, opened the file and without making changes, saved it at the same location and it worked!
> mochawesome-merge cypress/reports/*.json > cypress/reports/output.json ERROR: Failed to merge reports SyntaxError: cypress/reports/output.json: Unexpected end of JSON input at JSON.parse (<anonymous>) at C:\Mayank\Cypress_Code\node_modules\jsonfile\index.js:33:18 at C:\Mayank\Cypress_Code\node_modules\graceful-fs\graceful-fs.js:123:16 at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
Anyone have any solutions for the above issue in Windows 10
Open your 'package.json' file and make these three definations under scripts scetion,
"scripts": {
"cypress:test": "npx cypress run -b chrome -r mochawesome -s '.\\cypress\\integration\\examples\\api.js\\'",
"merge_reports": "mochawesome-merge cypress/report/mochawesome-report/*.json > cypress/report/output.json",
"report": "marge cypress/report/output.json --reportDir ./ --inline"
},
Now save the project and execute these scripts as,
' npm run cypress:test '
' npm run merge_reports '
' npm run report '
Copy the html file link from test execution and open it in browser.
Most helpful comment
Had the same issue. But got it solved after removing space.