Cypress Beginner Tutorial 11 | HTML Reports | Solution - Unexpected token � in JSON at position 0

Sdílet
Vložit
  • čas přidán 22. 11. 2021
  • Cypress Quiz - automationstepbystep.com/quiz...
    Cypress Udemy Course - bit.ly/3wJAdjq
    1. How to install mochawesome reporter
    2. How to configure the reporter
    3. How to merge multiple JSON report files
    4. How to generate a single HTML report
    5. Troubleshooting issues like
    Unexpected token � in JSON at position 0
    Unexpected end of JSON input
    6. Run reports command automatically using
    pretest and posttest scripts in package.json
    Step 1 - Install mochawesome library
    npm install mochawesome --save-dev
    Step 2 - Install mochawesome-merge library
    npm install mochawesome-merge --save-dev
    Step 3 - Add reports configuration in cypress.json
    {
    "reporter": "mochawesome",
    "reporterOptions": {
    "charts": true,
    "overwrite": false,
    "html": false,
    "json": true,
    "reportDir": "cypress/report/mochawesome-report"
    }
    }
    Step 4 - Run command to execute tests
    npx cypress run --reporter mochawesome
    Step 5 - Run command to merge multiple json reports into one
    npx mochawesome-merge cypress/report/mochawesome-report/*.json > cypress/report/output.json
    npx mochawesome-merge cypress/report/mochawesome-report/*.json | out-file -encoding ascii cypress/report/output.json
    Step 6 - Run command to generate html report
    npx marge cypress/report/output.json --reportDir ./ --inline
    Add report generation commands
    in package.json scripts
    pretest
    test
    posttest
    #CypressBeginnerTutorials
    Stories by Raghav - automationstepbystep.com/stor...
    You can support my mission for education by sharing this knowledge and helping as many people as you can
    If my work has helped you, consider helping any animal near you, in any way you can
    To save cows - radhasurabhi.com/donate/
    Never Stop Learning
    Raghav
    automationstepbystep.com/

Komentáře • 135

  • @erickdeazevedoalcantara7989
    @erickdeazevedoalcantara7989 Před 4 měsíci

    Awesome, thanks for your explanation.
    Greatings from Brazil.

  • @fatemamotiwala8554
    @fatemamotiwala8554 Před 3 měsíci

    Thank you for the videos. It a very detailed step by step process, so very easy to understand and follow.

    • @RaghavPal
      @RaghavPal  Před 3 měsíci

      You're very welcome Fatema

  • @emmimagilbert3850
    @emmimagilbert3850 Před rokem

    Taqqqq sir .... 😍😍 As a fresher ...this is very useful to me ... 😍

  • @xXMrThomasXx
    @xXMrThomasXx Před 11 dny

    Awesome tutorial :D Thx :)

  • @Shahzilrind
    @Shahzilrind Před 2 lety

    Great video thanks

  • @burgasdragonheirsilentgods

    Nice one !

  • @vitaliyovcharenko4991

    Thank you Raghav! It would be great if you add to this video some info about adding screenshots to mocha html report. It is very helpful feature allowing to see the problem point.

  • @paulc2317
    @paulc2317 Před rokem +2

    I think you don't need to type the word "run" inside the script execution line e.g.: "test": "npm run cypress" , and the again when you invoke the execution "npm run test", instead "npm test" would be enough. Also, a shortcut for the "Clear" DOS command is "clr"
    cheers

  • @lisazhou7776
    @lisazhou7776 Před 2 lety

    I follow your cypress tutorials. It is great. I am doing this test in work now. can you create how to debug cypress video

  • @deepaksingh2411
    @deepaksingh2411 Před 2 lety

    Great video sir. ❤️
    I had a question, how you use windows on your Mac device? Is it some virtual machine or boot camp you use?
    Please suggest me which one is better?

    • @RaghavPal
      @RaghavPal  Před 2 lety +1

      It's a remote machine Deepak

  • @josecaceres3516
    @josecaceres3516 Před 9 měsíci

    loveu

  • @amsofi
    @amsofi Před 2 lety

    Hi Raghav.first of all many thanks to your wonderful lessons. I am currently using cypress with BDD framework and I am running into an issue and do not know how to resolve. Kindly help me out. My applications works well with cypress framework but the data that involves lambda functions at the back end do not load when run from cypress. this happens only for the lambda calls. do you know what is blocking the data from displaying on the UI? any help on this is appreciated.

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Hi Sophia, will need to check the details, try checking some online examples

  • @Dushyantsahu10
    @Dushyantsahu10 Před 2 lety

    Awesome tutorial, Thanks Raghav
    Could you please guide me on how to deal with when the page doesn't have id available
    it has name, class and title

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Hi Dushyant, I will try to add a session on this, For now can check some examples online

    • @Dushyantsahu10
      @Dushyantsahu10 Před 2 lety

      @@RaghavPal I've tried so many online solution, that didnt help
      Still am trying the different methods available online, but eagerly waiting for your tutorial on iFrame handling
      Thanks :)

    • @RaghavPal
      @RaghavPal  Před 2 lety

      I will try to add

  • @mahedihasan2282
    @mahedihasan2282 Před 2 lety

    Thank you very much .when the next series will come.

  • @narendranandhu5845
    @narendranandhu5845 Před 2 lety

    Thank you, Raghav!
    Could you please tell me how to run a specific spec file instead of running all in the integration folder?... Thanks in advance

  • @rockinhillbilly
    @rockinhillbilly Před rokem

    Hi there, thank you for the wonderful tutorials.
    Regarding the end of the tutorial when we are using || and && in the scripts section of package.json, I could not get this to work. The posttest would run because the test script tells it to, but then the posttest would run, and effectively posttest would run twice. The first time it runs (via the test script) it creates the .json, with data, and then creates HTML file for report. However posttest then runs again (as it is programmed to always run after test), and then it runs the merge files command and overwrites the data in my .json file. It does not run the marge command, as we used &&, and the merge step failed.
    This is the only way I could get a .json file with data (note the test script stops after || .) -
    "scripts": {
    "pretest": "rm -r cypress/reports/*.json",
    "test": "npm run cy-test || :",
    "cy-test": "cypress run",
    "posttest": "npm run merge-reports && npm run html-report-gen",
    "merge-reports": "mochawesome-merge cypress/reports/*.json > cypress/reports/output20.json",
    "html-report-gen": "marge cypress/reports/output20.json --reportDir cypress/reports"
    },
    I would be curious to know how this works in your tutorial, if it does not work for me and I'm copying the exact code.
    Thanks :)

    • @RaghavPal
      @RaghavPal  Před rokem

      when you run test script, pretest and posttest will run before and after it, therefore we can adjust our commands accordingly in these scripts.
      You can modify them as per your needs

  • @nikhilgupta5721
    @nikhilgupta5721 Před 2 lety

    One big limitation in Cypress report I can see is that it only gets generated after all specs ran, we can not see the reports in between the execution. Let's say you have a regression suite contains many specs and would like to see are they running fine or not we can see only at the last and in that way let's say something goes wrong then we have waisted that much amount of time waiting for it to get complete of execution, just only one way of monitoring console for pass and fail but observing report is satisfying.

  • @TebarAnutTirto
    @TebarAnutTirto Před 11 měsíci

    Mr. Raghav thank you for the lesson ,but i still don t understand what is {script } for ?

    • @RaghavPal
      @RaghavPal  Před 11 měsíci

      Tebar
      Please point the time in the video, so I can check

  • @yashodharv5036
    @yashodharv5036 Před 2 lety

    Thank you raghav, actually i am getting html report if am running the commands individually but when i am running it by keeping in package.json, i think it is not getting read, i am not getting the html file not the merged report file

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Hi Yashodha, will need to check what exactly you are running in the script section of package.json, try some dummy command and see the syntax

  • @samiRediAmaniTekeshAlazar

    what is the advantage of using testscript compared to using js file? why dont we use just js files throughout our test project?

    • @RaghavPal
      @RaghavPal  Před 2 lety +1

      Hi, you can use JS only, TypeScript is a wrapper over JavaScript

  • @sasipriyakannan5742
    @sasipriyakannan5742 Před 8 měsíci

    Hi..
    I'm working in cypress automation tool. I had a challenge in generating reports. I'm performing parallelization in cypress where I couldn't get consolidated html report for the test that has been executed in parallel. Can you please suggest?

    • @RaghavPal
      @RaghavPal  Před 8 měsíci +1

      Sasipriya
      To generate a consolidated HTML report for parallel tests in Cypress, you can use the following steps:
      1. **Install the mochawesome-merge package.**
      ```
      npm install mochawesome-merge
      ```
      2. **Create a script to merge the individual JSON reports into a single JSON report.**
      ```
      node mochawesome-merge [path/to/report1.json] [path/to/report2.json] ... > [path/to/merged.json]
      ```
      3. **Generate the HTML report from the merged JSON report.**
      ```
      npx mochawesome [path/to/merged.json] > [path/to/report.html]
      ```
      Here is an example of a script that you can use to merge the individual JSON reports into a single JSON report:
      ```
      #!/bin/bash
      # Get the list of JSON report files
      report_files=$(find . -name "*.json" -type f)
      # Merge the JSON report files into a single JSON report
      mochawesome-merge $report_files > merged.json
      ```
      Here is an example of a command that you can use to generate the HTML report from the merged JSON report:
      ```
      npx mochawesome merged.json > report.html
      ```
      This will generate a consolidated HTML report in the current directory.
      There is also a Cypress plugin called `cypress-parallel-mocha` that can help you to generate a consolidated HTML report for parallel tests. To use this plugin, you will need to:
      1. **Install the cypress-parallel-mocha plugin.**
      ```
      npm install cypress-parallel-mocha
      ```
      2. **Configure the cypress-parallel-mocha plugin in your Cypress configuration file.**
      ```
      // cypress/config/index.js
      const cypressParallelMocha = require('cypress-parallel-mocha');
      module.exports = {
      ...
      plugins: [
      cypressParallelMocha
      ]
      };
      ```
      3. **Run your tests in parallel.**
      ```
      npx cypress run --parallel
      ```
      The cypress-parallel-mocha plugin will generate a consolidated HTML report in the `cypress/reports` directory.
      I hope this helps

  • @katharineponczoch1445
    @katharineponczoch1445 Před 2 lety +1

    i downloaded the latest version of cypress. it did not automatically generate a cypress.json file. is it found elsewhere in the current version of cypress, or do i need to create it somehow?

    • @RaghavPal
      @RaghavPal  Před 2 lety +1

      Hi Katharine, after you start cypress for the 1st time using command
      npx cypress open
      you should find the cypress.json file in the same folder where you ran the command

    • @ecatzkool7027
      @ecatzkool7027 Před rokem

      @@RaghavPal
      I am getting the same. I installed cypress 10.4.0. I do not have a cypress.json file (looked through the whole dir) even after a ran npx cypress open. However, I do have cypress.config.js. I believe the content should be in this file since I see the watchForFileChanges here. But it seems that it is ignored (does not go into the reportDir folder and overwrite seems to be true). Here is the content of cypress.config.js. Am I missing something? Thanks.
      -----------------------------------------
      const { defineConfig } = require("cypress");
      const {downloadFile} = require('cypress-downloadfile/lib/addPlugin')
      module.exports = defineConfig({
      e2e: {
      watchForFileChanges: false,
      reporter: 'mochawesome',
      reportOptions: {
      charts: true,
      overwrite: false,
      html: false,
      json: true,
      reportDir: './cypress/reports'
      },
      setupNodeEvents(on, config) {
      // implement node event listeners here
      on('task', {downloadFile})
      },
      },
      });

    • @ecatzkool7027
      @ecatzkool7027 Před rokem

      @@RaghavPal Realise my comment below is not to Raghav. Repost...
      I am getting the same. I installed cypress 10.4.0. I do not have a cypress.json file (looked through the whole dir) even after a ran npx cypress open. However, I do have cypress.config.js. I believe the content should be in this file since I see the watchForFileChanges here. But it seems that it is ignored (does not go into the reportDir folder and overwrite seems to be true). Here is the content of cypress.config.js. Am I missing something? Thanks.
      -----------------------------------------
      const { defineConfig } = require("cypress");
      const {downloadFile} = require('cypress-downloadfile/lib/addPlugin')
      module.exports = defineConfig({
      e2e: {
      watchForFileChanges: false,
      reporter: 'mochawesome',
      reportOptions: {
      charts: true,
      overwrite: false,
      html: false,
      json: true,
      reportDir: './cypress/reports'
      },
      setupNodeEvents(on, config) {
      // implement node event listeners here
      on('task', {downloadFile})
      },
      },

  • @hayathbasha4519
    @hayathbasha4519 Před 2 lety

    Hi sir,
    Can u pls let me know how to clear storage/cache before each cypress test file run

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Check this Hayath, stackoverflow.com/questions/46950668/does-cypress-clear-the-browser-cache-before-each-test

  • @prassanasrinivas7397
    @prassanasrinivas7397 Před 2 lety

    when i run npx cypress open am getting your pluginsFile is invalid plugins\index.js
    Unexpected token export in line 42 of index.js . any idea of what to change sir?
    please reply if someone knows it

    • @RaghavPal
      @RaghavPal  Před 2 lety +1

      Hi Prassana, check your plugins/index.js file and see what do you have at line no 42, sometimes it can be formatting issue too, Right click inside file and select Format Document and save and try

  • @pradipvaghela3179
    @pradipvaghela3179 Před 2 lety

    hi,raghav in this video at the last minutes. why not run cypress command in test section. why are you put again cypress run command again in test section. if there any reason

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Hi Pradip, pls mention the time, I will check

    • @pradipvaghela3179
      @pradipvaghela3179 Před 2 lety

      @@RaghavPal hi,raghav, time is between 30 to 35.

    • @RaghavPal
      @RaghavPal  Před 2 lety

      okay so in the test script I mentioned
      npm cypress run || npm run posttest
      Here the symbol || is used so that even if the 1st command (npm cypress run) fails i.e. even if any test fails, we still want to run the 2nd command (npm run posttest)

  • @vishnuvijayan6727
    @vishnuvijayan6727 Před rokem

    hello raghav,
    the below command is not working for me in mac,
    npx mochawesome-merge cypress/report/mochawesome-report/*.json | out-file -encoding ascii cypress/report/output.json,
    zsh: command not found: out-file

    • @RaghavPal
      @RaghavPal  Před rokem

      Hi Vishnu, will need to check the error and logs, pls refer some examples and try

  • @kairunbee1914
    @kairunbee1914 Před 2 lety

    Hi is it possible in cypress to run
    1. Specs file in parallel
    2. It block in parallel

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Yes, ideally when we have option to run from command line, we can get do it, also check docs.cypress.io/guides/guides/parallelization#Splitting-up-your-test-suite

  • @deekshaa4243
    @deekshaa4243 Před 2 lety

    Can you also show how to use Report Portal instead of Mochawesome reports

  • @socalledvinoth
    @socalledvinoth Před 2 lety

    Hi Raghav
    i'm getting this error in mac machine
    command not found: out-file

    • @RaghavPal
      @RaghavPal  Před 2 lety

      will need to check on this Vinoth, pls check if you have followed all the steps

    • @socalledvinoth
      @socalledvinoth Před 2 lety

      @@RaghavPal i missed -
      Now, It's working fine.
      Thanks for your response.

  • @hazimabdoh6303
    @hazimabdoh6303 Před rokem

    dear Mr Raghav , i cant countinue see the complete result when execute the test command : npm run test , becuase the following result appeared and didint precceed to the next steps : [mochawesome] Report JSON saved to C:\CypressProjects\ReportsDemo1\cypress
    eports\mochawesome.json.
    any help please .thanks

    • @RaghavPal
      @RaghavPal  Před rokem +1

      Hi Hazim, with these details I will not be able to know the reason, will need logs, Pls check all the steps again, Can check few online examples as well

    • @hazimabdoh6303
      @hazimabdoh6303 Před rokem

      @@RaghavPal dear Mr Raghav , i try it again and get successtesting , after reinstall and reconfigure every thing related , thanks a lot

  • @YovelHadad
    @YovelHadad Před rokem

    Hi Raghav.
    Can you make a tutorial for OAuth authentication of Application in UI ? 3-rd part side like google. Thank you

  • @brunoveiga9155
    @brunoveiga9155 Před 7 měsíci

    Hello Raghav. On 13:50, mine says: bash: out-file: command not found ERROR: Failed to merge reports. Do you know how I can fix this? It might be because I am doing it from a MacOs. Thank you.

    • @RaghavPal
      @RaghavPal  Před 7 měsíci

      Not very sure if that is the reason for this Bruno, can check some online examples

    • @brunoveiga9155
      @brunoveiga9155 Před 7 měsíci

      @@RaghavPal I solved it, thanks

  • @prabhumishra3323
    @prabhumishra3323 Před 2 lety

    How to send the report in mail to the team because the html files are dependent on assets folder

    • @RaghavPal
      @RaghavPal  Před 2 lety

      you can create an mhtml file and then send it OR
      use Cypress Dashboard and add all team members

  • @slobodanparizoski6869

    If someone is facing any issues using the rimraf -r command to delete json report files form the previous test runs, just use this in "pretest":
    "pretest": "cd (relative path to your reports folder) && del *.json"
    In my case it was: "pretest": "cd ./cypress/report/mochawesome-report && del *.json"
    I came up with this after trying all other possible solutions which did not resolved the issue. And this worked for me.

    • @RaghavPal
      @RaghavPal  Před rokem

      Thanks for adding Slobodan, I will help others

  • @user-xh4qj6yp1o
    @user-xh4qj6yp1o Před rokem

    Why do I get an error saying
    'unknown option: -r
    run 'rimraf --help' for usage information'
    when trying to run the pretest and how do I fix it?

    • @RaghavPal
      @RaghavPal  Před rokem

      The error message "unknown option: -r run 'rimraf --help' for usage information" usually occurs in Cypress when there is an issue with the command that you are trying to execute.
      The "-r" option is not a valid option for Cypress. It is possible that you have added this option to the Cypress command by mistake, or that it is specified in the configuration file.
      To fix this issue, you should check your Cypress configuration file (cypress.json) to see if the "-r" option is specified. If it is, remove it and try running the command again.
      If the issue persists, it could be that there is a problem with the way that the pretest command is being executed. In this case, you may need to review the script that is running the command and check that it is correctly invoking Cypress.
      It is also worth checking that you have installed all the necessary dependencies and packages for Cypress to run, such as Node.js, Cypress, and any plugins or extensions that you may need.
      If none of these solutions work, you can try reaching out to the Cypress community for further support or troubleshooting assistance.

  • @shoonyakumari
    @shoonyakumari Před měsícem

    Hi Raghav, Thank you for sharing the knowledge and for your time spending for this videos. If possible could you please add the new video for reports using the latest versions because I am keep getting ERROR: Failed to merge reports Error: Pattern. Tried in online but not resolved.
    "cypress": "^13.9.0",
    "cypress-mochawesome-reporter": "^3.8.2",
    "mochawesome-merge": "^4.3.0"

    • @RaghavPal
      @RaghavPal  Před měsícem

      Okay Shoonya.. There is also Cypress Masterclass on a newer version. Can check here - automationstepbystep.com/

    • @shoonyakumari
      @shoonyakumari Před měsícem

      @@RaghavPal Hi Raghav, Yes I watched all those 4 latest masterclass videos however reports not covered on those and suggest to watch this video only.
      TBH all your videos are very useful and able to do the basic frameworks from scratch.
      Just a request if possible please cover the latest reports, , window, alert popup messages to accepting cookies.
      (If i am not wrong in latest versions spec reports are creating by default and no need to merge anymore but please correct me if i am wrong).

    • @RaghavPal
      @RaghavPal  Před měsícem

      ok, if i get sometime i will plan to create a new session for this

  • @syedghouse1696
    @syedghouse1696 Před 2 lety

    Cypress reload causing blank page
    Can u pls advise alternative way for reload

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Hi Syed, you can restart and check

  • @fatemamotiwala8554
    @fatemamotiwala8554 Před 3 měsíci +2

    I was stuck at rimraf, as it was deleting the folder but it gave an error invalid path for any files *.json or *.*. So, modify the command as "pretest": "rimraf ./cypress/report/*.json --glob", --glob helps it to identify the *sign. Hope it helps if someone is facing same issue

    • @RaghavPal
      @RaghavPal  Před 3 měsíci

      Thanks for posting Fatema.. I am sure this will help many

  • @nicolasma7424
    @nicolasma7424 Před rokem

    Hi Raghav, me again :) I don't see anything about Unexpected token � in JSON at position 0 in this video.. I'm trying to implement BrowsertStack in my testing solution but end up with this error message "SyntaxError: Unexpected token C in JSON at position 0". Any idea how to fix it ?
    I know you said you are going to create a video for BrowserStack and Jenkins but I saw this video's title and though it would help me :)
    Thanks for your help

    • @RaghavPal
      @RaghavPal  Před rokem

      I will check on this and update

    • @nicolasma7424
      @nicolasma7424 Před rokem

      @@RaghavPal Thanks. Your video's title is "Solution - Unexpected token � in JSON at position 0" so I thought you were talking about it.

    • @RaghavPal
      @RaghavPal  Před rokem

      I have this section in the video, pls check

    • @nicolasma7424
      @nicolasma7424 Před rokem

      @@RaghavPal Is there ? Can you please point at the timestand ? I can't find it :/

    • @RaghavPal
      @RaghavPal  Před rokem

      Pls check 12:43

  • @martinkazda2571
    @martinkazda2571 Před 2 lety

    Hello. I have to say that your great guides really help me. But i have issue in this project. When i use run the pretest in form: "rm -r ./cypress/report/*.json". Test is stopped with message: rm: cannot remove './cypress/report/*.json': No such file or directory. Do you have any idea what is the reason fot that? When the .json file is in directory everything works fine. Thank you for your answer :).

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Hi Martin, did you try this command separately, from the terminal, Also, in case of windows, use rimraf instead of rm

  • @satyanarayanas6769
    @satyanarayanas6769 Před rokem

    npm ERR! could not determine executable to run
    i got this error before step 6

    • @RaghavPal
      @RaghavPal  Před rokem

      Can reinstall or use a diff version

  • @LeIsaiahsss
    @LeIsaiahsss Před 2 měsíci

    it didn't generate any videos and screenshots for me when I ran the cypress test

    • @RaghavPal
      @RaghavPal  Před 2 měsíci

      Justin
      Let's address the issue with generating videos and screenshots in Cypress HTML reports
      1. Screenshots:
      - Cypress provides built-in support for taking screenshots during test execution.
      - To manually capture a screenshot, you can use the `cy.screenshot()` command in your test code.
      - By default, Cypress automatically captures screenshots when a test fails during `cypress run`.
      - Note that screenshots on failure are not automatically taken during `cypress open`.
      - You can configure the screenshots folder by setting the `screenshotsFolder` option in your `cypress.json` file⁵.
      - If you're not seeing screenshots, ensure that the configuration is correctly set and that the folder exists.
      2. Videos:
      - Cypress supports video recording for Chromium-based browsers (Chrome, Electron, Edge).
      - Video recording is disabled by default but can be enabled by setting `video: true` in your configuration.
      - During `cypress run`, Cypress records a video for each spec file.
      - Videos are not recorded during `cypress open`.
      - Videos are stored in the `videosFolder`, which is set to `cypress/videos` by default.
      - When using the `--record` flag, videos are processed, compressed, and uploaded to Cypress Cloud after each spec file run.
      - You can control video compression using the `videoCompression` option⁵.
      3. Troubleshooting Tips:
      - If you're still facing issues:
      - Look at the video recordings and screenshots.
      - Split large spec files into smaller ones.
      - Split long tests into smaller tests.
      - Run the same test using `--browser chrome` to check if the problem is isolated to the Electron browser.
      - Compare screenshots/videos between Electron and Chrome runs⁸.
      Remember to verify your configuration settings and ensure that the necessary folders exist

  • @vineethpenki6247
    @vineethpenki6247 Před 3 měsíci +1

    ERROR: Failed to merge reports
    Error: Pattern .\\cypress\
    eports\\*.json matched no report files
    at C:\Users\2100289\cypress automation
    ode_modules\mochawesome-merge\lib\index.js:14:11
    at Array.map ()
    at C:\Users\2100289\cypress automation
    ode_modules\mochawesome-merge\lib\utils.js:3:46
    at merge (C:\Users\2100289\cypress automation
    ode_modules\mochawesome-merge\lib\index.js:84:17)
    at Object. (C:\Users\2100289\cypress automation
    ode_modules\mochawesome-merge\bin\mochawesome-merge.js:32:1)
    it showing error like this what it means could you please tell

    • @RaghavPal
      @RaghavPal  Před 3 měsíci

      Vineeth
      The error message you're seeing is related to the `mochawesome-merge` module, which is used to merge multiple Mochawesome JSON reports into one. The error message `Pattern .\\cypress\
      eports\\*.json matched no report files` indicates that the module is unable to find any JSON report files in the specified directory (`.\\cypress\
      eports\\`).
      This could be due to a few reasons:
      1. No report files exist: If no tests have been run, or if all tests have passed (depending on your configuration), no report files may have been generated in the first place
      2. Incorrect directory: The directory provided might not be correct. Ensure that the path specified is the one where the JSON reports are being generated
      3. Path format: The path format could be incorrect due to the use of different slashes. Try changing the slashes
      To resolve this issue, you could check the following..
      - Ensure that tests have been run and that they generate a report file.
      - Verify the directory path to make sure it points to the correct location of the report files.
      - Check your `mochawesome-merge` command and ensure it's correctly formatted
      .

    • @vineethpenki6247
      @vineethpenki6247 Před 3 měsíci

      Yeah thank u it’s working 🙏

  • @mehrunisa929
    @mehrunisa929 Před 6 měsíci

    There is no cypress.json file in my vs code why is it so and how can I get it ?

    • @RaghavPal
      @RaghavPal  Před 6 měsíci +1

      Mehru
      Here's why you might not have a cypress.json file in your VS Code project, and how to get it:
      1. New Cypress Project:
      Cypress doesn't automatically create a cypress.json file when you start a new project. You'll need to generate it manually.
      2. Older Cypress Version:
      In Cypress versions older than 9.0, the configuration file was named cypress.config.js. If you're using an older version, look for that file instead.
      3. Incorrect Project Structure:
      The cypress.json file should be located in the root directory of your Cypress project. If it's not there, it might be in a different location or not yet created.
      How to Get the cypress.json File:
      1. Manual Creation:
      Right-click in the root directory of your Cypress project in VS Code.
      Select "New File" and name it cypress.json.
      2. Cypress Command (Newer Versions):
      Open a terminal in your project directory.
      Run the command npx cypress open.
      This will launch Cypress and create a default cypress.json file if it doesn't exist.
      Once you have the cypress.json file, you can customize your Cypress configuration within it.
      Key Points:
      The cypress.json file is essential for configuring various Cypress settings, such as:
      Test files to run
      Base URL for tests
      Environment variables
      Browser preferences
      Plugins
      If you're using Cypress 9.0 or newer, you can also use a cypress.config.js file for configuration.

    • @mehrunisa929
      @mehrunisa929 Před 6 měsíci

      you are so helpful thank you so much. God bless you@@RaghavPal

  • @equalityx3376
    @equalityx3376 Před rokem

    How to do this on vr

  • @sagark1556
    @sagark1556 Před rokem

    I was facing an issue while merging
    Here is the problem statement
    ERROR: Failed to merge reports
    Error: Pattern cypress/reports/mocha/*.json matched no report files
    **Solved -
    changed the legacy command:
    from:
    mochawesome-merge cypress/reports/mocha/*.json > cypress/reports/report.json
    to:
    mochawesome-merge cypress/reports/mocha/*.json -o cypress/reports/report.json

    • @RaghavPal
      @RaghavPal  Před rokem

      Thanks for adding Sagar. This will help others

  • @HHHorea
    @HHHorea Před 2 lety

    where is tutorial number 10? :)

    • @RaghavPal
      @RaghavPal  Před 2 lety

      find all here - automationstepbystep.com/

  • @dougm118
    @dougm118 Před 2 měsíci +1

    ascii is pronounced as-KEY sir not as-KAI. :). I'm listening to you and I'm
    like... what did he say?

    • @RaghavPal
      @RaghavPal  Před 2 měsíci

      Thanks for correcting Doug. will remember

    • @dougm118
      @dougm118 Před 2 měsíci

      @@RaghavPal Sure. Do you have any tutorials on using Cypress with an application within an iFrame? Unfortunately, the application I wanted to test is housed in an . I found various solutions from folks on StackOverflow but it is a shame that the Inspector from Cypress does not work to identify elements contained in an . I like your approach to breaking things down into simple steps and walking through some common online solution or your own would be helpful.

    • @dougm118
      @dougm118 Před 2 měsíci

      @@RaghavPal Also the e in echo is a short e sound like in the word bet, check, metal...Eh co not EE co. For Windows, use "pretest" : "del .\\path-to-json-files\\*.json". No need for rimraf. Also for a PC: "merge-reports": "mochawesome-merge mochawesome-report/*.json > out-file -encoding ascii output.json",
      Thank you for this helpful video.

    • @RaghavPal
      @RaghavPal  Před 2 měsíci

      not yet

  • @aartiriat7590
    @aartiriat7590 Před měsícem

    Hi @raghav,
    when i am trying to run the pretest at 28:00 using rimraf i am getting below error:
    > reportingproject@1.0.0 pretest
    > rimraf -r ./cypress/reports/*.json
    unknown option: -r
    run `rimraf --help` for usage information
    Can you please help?

    • @RaghavPal
      @RaghavPal  Před měsícem

      Aarti
      The error message you're seeing is because `rimraf` does not recognize the `-r` option. The `rimraf` command is used to delete files and directories, and it does not require the `-r` option like the `rm -r` command in Unix-based systems.
      You should modify your script in the `package.json` file to remove the `-r` option. Here's how your script should look:
      ```json
      "scripts": {
      "pretest": "rimraf ./cypress/reports/*.json"
      }
      ```
      Now, when you run your pretest script, it should correctly delete all `.json` files in the `./cypress/reports/` directory without any errors. If the directory itself needs to be deleted, you can specify the directory without the `/*.json`:
      ```json
      "scripts": {
      "pretest": "rimraf ./cypress/reports"
      }
      ```
      This will delete the `reports` directory itself. Please try
      --

    • @aartiriat7590
      @aartiriat7590 Před měsícem

      @raghav: thanks a ton

  • @pradipvaghela3179
    @pradipvaghela3179 Před 2 lety

    Hi, Brother. i facing access denied during the scripts in terminal using this -> npm run merge-report
    > mocha_report_prog@1.0.0 merge-report
    > mochawesome-merge ./cypress/reports/*.json > ./ report11.json
    Access is denied.
    can you please help me out whats needs to be require for this

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Hi Pradip, will need more logs to troubleshoot, Check all the steps and setup again

  • @mahasakka2594
    @mahasakka2594 Před 2 měsíci

    HELLO,
    how can I correct this issue ?
    npx mochawesome-merge ./cypress/reports/*.json > ./cypress/reports/output.json
    >>
    ERROR: Failed to merge reports
    Error: Pattern > matched no report files
    at D:\Cypress\Project 1
    ode_modules\mochawesome-merge\lib\index.js:14:11
    at Array.map ()
    at D:\Cypress\Project 1
    ode_modules\mochawesome-merge\lib\utils.js:3:46
    at merge (D:\Cypress\Project 1
    ode_modules\mochawesome-merge\lib\index.js:84:17)
    at Object. (D:\Cypress\Project 1
    ode_modules\mochawesome-merge\bin\mochawesome-merge.js:32:1)
    at Module._compile (node:internal/modules/cjs/loader:1480:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
    at Module.load (node:internal/modules/cjs/loader:1287:32)
    at Module._load (node:internal/modules/cjs/loader:1103:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:168:12)

    • @RaghavPal
      @RaghavPal  Před 2 měsíci

      The error message you're encountering indicates that the `mochawesome-merge` command failed to merge the reports due to a pattern matching issue. Let's address this step by step:
      1. Pattern Matching Issue:
      - The error specifically states: "Error: Pattern > matched no report files."
      - This means that the pattern you provided (`./cypress/reports/*.json`) did not match any report files in the specified directory.
      2. Solution:
      - To resolve this, let's adjust the command to ensure that it correctly identifies the report files.
      - Instead of using `>` (which is not a valid pattern), use `*` to match all JSON files in the `./cypress/reports/` directory.
      - Here's the corrected command:
      ```
      npx mochawesome-merge ./cypress/reports/*.json > ./cypress/reports/output.json
      ```
      3. Additional Considerations:
      - Make sure that the `./cypress/reports/` directory contains the expected JSON report files.
      - Verify that the file names follow the pattern you're using (e.g., `report1.json`, `report2.json`, etc.).
      4. Version 4 Update:
      - If you're using version 4 of `mochawesome-merge`, note that it no longer accepts the `--reportDir` option.
      - Instead, specify a list of file paths or glob patterns directly (separated by spaces).
      - For example:
      ```
      npx mochawesome-merge ./cypress/reports/mocha/*.json > ./cypress/reports/output.json
      ```
      Try the corrected command, and it should successfully merge the reports into the `output.json` file

  • @musikaphtv6727
    @musikaphtv6727 Před 2 lety

    Hi Raghav, I tried this activities and I got this
    PS D:\Cypress\Project1> npx cypress run --reporter mochawesome
    'chcp' is not recognized as an internal or external command,
    operable program or batch file.
    Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:480:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
    {
    errno: -4058,
    code: 'ENOENT',
    syscall: 'spawn cmd',
    path: 'cmd',
    spawnargs: [
    '/c',
    'WMIC path win32_process get Name,Processid,ParentProcessId,Commandline,ExecutablePath'
    ]
    }
    Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:480:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
    Please help me.

    • @RaghavPal
      @RaghavPal  Před 2 lety

      Hi, this can help stackoverflow.com/questions/8142058/chcp-is-not-recognized-as-an-internal-or-external-command-operable-program-or

  • @vikum08
    @vikum08 Před měsícem

    Hi Rahav
    When I am running 'npm run pretest' I am always getting this error "unknown option: -r"
    My code is - "pretest": "rimraf -r ./cypress/reports/*.json", and I already install "rimraf" too. Can you help me to resolve this issue plz?

    • @RaghavPal
      @RaghavPal  Před měsícem

      Vikum
      Here are few things you can check for the issue with the "unknown option: -r" error when running `npm run pretest`.
      1. Incorrect Usage of `rimraf`:
      - The issue lies in the usage of `rimraf`. The `-r` flag is not valid for `rimraf`.
      - `rimraf` is used to delete files and directories, but it doesn't require the `-r` flag. Instead, it automatically handles recursive deletion.
      - To fix this, remove the `-r` flag from your script.
      2. Update Your Script:
      - Modify your `package.json` script to remove the `-r` flag:
      ```json
      "scripts": {
      "pretest": "rimraf ./cypress/reports/*.json"
      }
      ```
      - Now, running `npm run pretest` should work as expected.
      3. Run the Command:
      - After updating your script, execute `npm run pretest` again.
      4. Additional Notes:
      - If you encounter any other issues, ensure that you have the correct version of `rimraf` installed (`npm install rimraf --save-dev`).
      - Also, make sure that the path to your `.json` files is correct.
      Remember to remove the `-r` flag from your script, and your `pretest` command should work without any errors
      -

    • @vikum08
      @vikum08 Před měsícem

      @@RaghavPal Thanks Raghav your comments highly appreciate it

  • @vighneshmane2080
    @vighneshmane2080 Před 5 měsíci +2

    to remove the json files the command rm is not recognized,
    ------------------------------------------------------------------------------------------------
    > project1@1.0.0 pretest
    > rm -r ./cypress/reports/*.json
    'rm' is not recognized as an internal or external command,
    operable program or batch file.
    -----------------------------------------------------------------------------------------------
    even if i use rimraf
    --------------------------------------------------------------------
    > project1@1.0.0 pretest
    > rimraf -r ./cypress/reports/*.json
    unknown option: -r
    run `rimraf --help` for usage information
    ---------------------------------------------------------------------
    please help me out anyone

    • @RaghavPal
      @RaghavPal  Před 5 měsíci +1

      If someone is facing any issues using the rimraf -r command to delete json report files form the previous test runs, just use this in "pretest":
      "pretest": "cd (relative path to your reports folder) && del *.json"
      In my case it was: "pretest": "cd ./cypress/report/mochawesome-report && del *.json"
      this worked for me.