json-formatter icon indicating copy to clipboard operation
json-formatter copied to clipboard

cucumber-json-formatter for macOS is not working (cucumber-json-formatter ENOENT)

Open adinizs opened this issue 3 years ago • 26 comments

After run the tests an error is displayed:

An error was thrown in your plugins file while executing the handler for the after:run event.

The error we received was:

Error: spawn cucumber-json-formatter ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:478:16) at processTicksAndRejections (node:internal/process/task_queues:83:21)

I downloaded the file cucumber-json-formatter-darwin-amd64 and followed the steps as described in the readme, but this error is displayed.

Obs: I using macOS with apple silicon chip (M1)

My .cypress-cucumber-preprocessorrc.json file:

{ "json": { "enabled": true, "output": "jsonlogs/log.json", "formater": "cucumber-json-formatter" }, "messages": { "enabled": true, "output": "jsonlogs/messages.ndjson" }, "stepDefinitions": [ "[filepath]/**/.{js,ts}", "[filepath].{js,ts}", "cypress/support/step_definitions/.{js,ts}" ] }

adinizs avatar Aug 01 '22 12:08 adinizs

I have same issue on Mac Error: spawn cucumber-json-formatter ENOENT

AfganSh avatar Aug 14 '22 03:08 AfganSh

I am trying to migrate cypress to 10+, but I am getting an error while creating the cucumber report as below on M1 mac, could anyone please help me with it.

An error was thrown in your plugins file while executing the handler for the after:run event.

The error we received was:

Error: spawn cucumber-json-formatter ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:478:16) at processTicksAndRejections (node:internal/process/task_queues:83:21)

Have the same issue like above

Thank you!

radhakrishnanakireddy avatar Aug 23 '22 16:08 radhakrishnanakireddy

FYI, this project and its authors have no relationship with Cypress nor the cypress-cucumber-preprocessor.

The errors mentioned here indicated that you have not successfully made the executable available in your PATH. The PATH variable has to include a directory containing cucumber-json-formatter (or whichever name you've configured) and it has to have execute permissions. Any failure in this results in ENOENT.

badeball avatar Aug 23 '22 16:08 badeball

@badeball Thanks for the update, cucumber-json-formatter is in path of cypress project and have the below config

{
    "json": {
      "enabled": true,
      "output": "jsonlogs/log.json",
      "formater": "cucumber-json-formatter"
    },
    "messages": {
      "enabled": true,
      "output": "jsonlogs/messages.ndjson"
    },
    "html": {
      "enabled": true
    },
    "stepDefinitions": [
        "[filepath]/**/*.{js,ts}",
        "[filepath].{js,ts}",
        "cypress/e2e/step_definitions/*.{js,ts}"
    ]
}

I did the samething on windows, its working fine, but facing this issue on mac Could you please provide little insight of it

Thank you!

radhakrishnanakireddy avatar Aug 23 '22 17:08 radhakrishnanakireddy

Hi.

I have been trying to get the cucumber-json-formatter working on my MacBook. I have been using the instructions on their GitHub page - https://github.com/cucumber/json-formatter

I followed these steps (as suggested on the GitHub page):-

MacOS

    • Download cucumber-json-formatter-darwin-amd64 and rename it to cucumber-json-formatter
    • Move it to a directory that's on your PATH
    • Make it executable with chmod +x cucumber-json-formatter
    • Verify that you can run it: cucumber-json-formatter --help At the last step, you may get a security warning from MacOS. If you do, open System Preferences. Go to Security Settings. You should see a question asking if you want to open it anyway. Say yes.

When I run the command in step 4. I get the following error:- cucumber-json-formatter: command not found

Further information - I am doing this on a M1 MacBook.

ashort-zaizi avatar Aug 24 '22 20:08 ashort-zaizi

@ashort-zaizi I have an M1 Mac and what I needed to do for step 4 to work was manually opening the cucumber-json-formatter file, only then my Mac allowed me to use it.

Besides that, make sure to open a new terminal session to read your updated PATH , run echo $PATH just for the sake of it and if you can see your folder containing the cucumber-json-formatter, then cucumber-json-formatter --help should work

a8trejo avatar Aug 25 '22 21:08 a8trejo

Hi a8rejo. When you say manually open the cucumber-json-formatter, what do you mean? Double click on the file?

ashort-zaizi avatar Aug 26 '22 08:08 ashort-zaizi

Hi @a8trejo I double clicked on the cucumber-json-formatter file, and allowed the permission, but the error is the same.

adinizs avatar Aug 26 '22 12:08 adinizs

@ashort-zaizi yes, as @adinizs did @adinizs when you run echo $PATH do you see the folder where your cucumber-json-formatter file is?

If it helps for reference, this is what I do on a Github Actions workflow to get it working too,

- name: Set Up Environment
  run: |
    mkdir cypress/config/cucumber_json
    echo "${{ github.workspace }}/cypress/config/cucumber_json" >> $GITHUB_PATH
    cd cypress/config/cucumber_json
    curl https://github.com/cucumber/json-formatter/releases/download/v19.0.0/cucumber-json-formatter-linux-amd64 -o cucumber-json-formatter
    chmod +x cucumber-json-formatter

Note: the curl is using the ubuntu file as the Github workflow uses an ubuntu image

a8trejo avatar Aug 26 '22 17:08 a8trejo

as for how to set the folder where cucumber-json-formatter is located, into your PATH, if I have it in /Users/myUserName/Workspace/tools/path/cucumber-json-formatter I do it with: vi ~/.zprofile and I add:

# Cucumber Standalone JSON Formatter
CUSTOM_FOLDER=/Users/myUserName/Workspace/tools/path
export PATH=$CUSTOM_FOLDER:$PATH

a8trejo avatar Aug 26 '22 18:08 a8trejo

I set this information in my .zprofile, but the error is the same. @a8trejo

# Cucumber Standalone JSON Formatter
CUSTOM_FOLDER=/Users/diniz/Projects/qa
export PATH=$CUSTOM_FOLDER:$PATH

adinizs avatar Aug 26 '22 18:08 adinizs

@adinizs also close and reopen Visual Studio or the terminal so it reads the system variable again, if that still doesn't work, I'm out of ideas ^^

a8trejo avatar Aug 26 '22 18:08 a8trejo

@adinizs what is the output of your echo $PATH ?

a8trejo avatar Aug 26 '22 18:08 a8trejo

I got it!!

Steps for success:

MacOS

  1. Download cucumber-json-formatter-darwin-amd64 and rename it to cucumber-json-formatter
  2. Move it to a directory that's on your PATH
  3. Set in your ~/.zprofile the follow information:
# Cucumber Standalone JSON Formatter
CUSTOM_FOLDER=/Users/YourUser/Workspace/path
export PATH=$CUSTOM_FOLDER:$PATH
  1. Restart your terminal and VS Code (or your code editor)
  2. Make it executable with chmod +x cucumber-json-formatter
  3. Verify that you can run it: cucumber-json-formatter --help

Thank you @a8trejo !!

adinizs avatar Aug 26 '22 18:08 adinizs

happy to help! :D

a8trejo avatar Aug 26 '22 18:08 a8trejo

@badeball Thanks for the update, cucumber-json-formatter is in path of cypress project and have the below config

{
    "json": {
      "enabled": true,
      "output": "jsonlogs/log.json",
      "formater": "cucumber-json-formatter"
    },
    "messages": {
      "enabled": true,
      "output": "jsonlogs/messages.ndjson"
    },
    "html": {
      "enabled": true
    },
    "stepDefinitions": [
        "[filepath]/**/*.{js,ts}",
        "[filepath].{js,ts}",
        "cypress/e2e/step_definitions/*.{js,ts}"
    ]
}

I did the samething on windows, its working fine, but facing this issue on mac Could you please provide little insight of it

Thank you!

I am able to solve it after following adinizs steps.

adinizs thanks!

radhakrishnanakireddy avatar Aug 30 '22 14:08 radhakrishnanakireddy

I have added cucumber-json-formatter to my PATH . I have updated my system preferences to allow my MacBook to open the cucumber-json-formatter executable.

When I open a terminal window and run the following command :-- cucumber-json-formatter --help

I can see that I have configured my PATH variable correctly as I see this response in the terminal window:- Usage of cucumber-json-formatter:

When I open VSCode and open a terminal window within VSCode and run the following command:- cucumber-json-formatter --help

I get this response:- bash: cucumber-json-formatter: command not found

I have tried closing and re-opening VSCode, but I see the same error. Im very confused in what to do now. Any help would be much appreciated. Thanks!

ashort-zaizi avatar Sep 04 '22 20:09 ashort-zaizi

I found the problem!!

in macOS we need to create a .bash_profile file, in this file we need to add environmental variables and add macOS path.

Maybe I don't describe very well the solution but I gonna attach a imag

Steps:

  1. macOS *Download cucumber-json-formatter-darwin-amd64 and rename it to cucumber-json-formatter *Move it to a directory that's on your PATH *Make it executable with chmod +x cucumber-json-formatter

2.Create file .bash_profile (/Users/your user)

  1. Add into .bash_prifile the next: export CUSTOM_FOLDER="directory that's on your PATH. the same in the step 1 " export PATH=$CUSTOM_FOLDER:$PATH
Captura de Pantalla 2022-12-12 a la(s) 18 58 15
  1. Open terminal an run an type source ~/.bash_profile (activate environment variables)

  2. Verify that you can run it: cucumber-json-formatter --help

Captura de Pantalla 2022-12-12 a la(s) 18 48 25

whit this step I can make a report Captura de Pantalla 2022-12-12 a la(s) 19 00 39

LPalomeque99 avatar Dec 12 '22 23:12 LPalomeque99

It depends on your MAC Operating system, ~/.bash_profile won't work for all MACs, ~/.zprofile works in mine, but the root cause/solution is the same

Make sure the system variable $PATH (nothing related to any cypress config file or path at all), includes the path where cucumber-json-formatter is

How to update the system variable $PATH , changes depending on the operating system

a8trejo avatar Dec 13 '22 00:12 a8trejo

FIX:

Have stumbled a similar problem when I was following a certain course. If ever your cucumber-json-formatter is moved inside your project, you only need to add "./" in your formatter path in order to run that executable file

image

and the ENOENT error will not persist anymore inside the terminal after running $cypress run and will generate the /jsonlogs folder based on your configuration

image

KShewengger avatar Mar 21 '23 05:03 KShewengger

@KShewengger thank you, thank you!! "formatter": "./cucumber-json-formatter" fixed my issue.

w4dd325 avatar Mar 31 '23 18:03 w4dd325

Hello @badeball,

Firstly, many thanks for your helping library which is very useful.

I have followed exact steps but couldn't generate json file on my mac and also on linux. I have also followed all above suggestions but no luck, please can you help as I'm currently blocked :(? Below are details from my mac and our project is mono repo project.

@adinizs @KShewengger I have followed your steps too but no luck. Please help if you can.

Package.json

image

Formatter is present at root folder

image

PATH Variable

Added in .bash_profile

image

Result from command

image

Debug log

DevTools listening on ws://127.0.0.1:52532/devtools/browser/6d6f2fb9-1346-48bb-8097-555a1c01e87f cypress-cucumber-preprocessor resolved environment overrides {} +0ms cypress-cucumber-preprocessor resolved explicit user configuration { cypress-cucumber-preprocessor json: { enabled: true, output: 'jsonlogs' }, cypress-cucumber-preprocessor messages: { enabled: true, output: 'messages.ndjson' }, cypress-cucumber-preprocessor stepDefinitions: [ './apps/host-e2e/src/support/step_definitions/.js' ] cypress-cucumber-preprocessor } +1ms cypress-cucumber-preprocessor resolved configuration { cypress-cucumber-preprocessor stepDefinitions: [ './apps/host-e2e/src/support/step_definitions/.js' ], cypress-cucumber-preprocessor messages: { enabled: true, output: 'messages.ndjson' }, cypress-cucumber-preprocessor json: { enabled: true, output: 'jsonlogs' }, cypress-cucumber-preprocessor html: { enabled: false, output: 'cucumber-report.html' }, cypress-cucumber-preprocessor pretty: { enabled: false }, cypress-cucumber-preprocessor filterSpecsMixedMode: 'hide', cypress-cucumber-preprocessor filterSpecs: false, cypress-cucumber-preprocessor omitFiltered: false, cypress-cucumber-preprocessor implicitIntegrationFolder: '/', cypress-cucumber-preprocessor isTrackingState: true cypress-cucumber-preprocessor } +1ms

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Cypress: 13.13.0 │ │ Browser: Electron 118 (headless) │ │ Node Version: v20.12.2 (/Users/pavgurra/.nvm/versions/node/v20.12.2/bin/node) │ │ Specs: 1 found (upl-e2e-journeys.feature) │ │ Searched: apps/host-e2e/src/integration/e2e/upl/upl-e2e-journeys.feature │ │ Experiments: experimentalMemoryManagement=true │ └────────────────────────────────────────────────────────────────────────────────────────────────┘

cypress-cucumber-preprocessor beforeRunHandler() +2s cypress-cucumber-preprocessor resolved environment overrides {} +2ms cypress-cucumber-preprocessor resolved explicit user configuration { cypress-cucumber-preprocessor json: { enabled: true, output: 'jsonlogs' }, cypress-cucumber-preprocessor messages: { enabled: true, output: 'messages.ndjson' }, cypress-cucumber-preprocessor stepDefinitions: [ './apps/host-e2e/src/support/step_definitions/.js' ] cypress-cucumber-preprocessor } +0ms cypress-cucumber-preprocessor resolved configuration { cypress-cucumber-preprocessor stepDefinitions: [ './apps/host-e2e/src/support/step_definitions/.js' ], cypress-cucumber-preprocessor messages: { enabled: true, output: 'messages.ndjson' }, cypress-cucumber-preprocessor json: { enabled: true, output: 'jsonlogs' }, cypress-cucumber-preprocessor html: { enabled: false, output: 'cucumber-report.html' }, cypress-cucumber-preprocessor pretty: { enabled: false }, cypress-cucumber-preprocessor filterSpecsMixedMode: 'hide', cypress-cucumber-preprocessor filterSpecs: false, cypress-cucumber-preprocessor omitFiltered: false, cypress-cucumber-preprocessor implicitIntegrationFolder: '/', cypress-cucumber-preprocessor isTrackingState: true cypress-cucumber-preprocessor } +0ms

────────────────────────────────────────────────────────────────────────────────────────────────────

Running: upl-e2e-journeys.feature (1 of 1) cypress-cucumber-preprocessor beforeSpecHandler() +2s cypress-cucumber-preprocessor resolved environment overrides {} +66ms cypress-cucumber-preprocessor resolved explicit user configuration { cypress-cucumber-preprocessor json: { enabled: true, output: 'jsonlogs' }, cypress-cucumber-preprocessor messages: { enabled: true, output: 'messages.ndjson' }, cypress-cucumber-preprocessor stepDefinitions: [ './apps/host-e2e/src/support/step_definitions/.js' ] cypress-cucumber-preprocessor } +0ms cypress-cucumber-preprocessor resolved configuration { cypress-cucumber-preprocessor stepDefinitions: [ './apps/host-e2e/src/support/step_definitions/.js' ], cypress-cucumber-preprocessor messages: { enabled: true, output: 'messages.ndjson' }, cypress-cucumber-preprocessor json: { enabled: true, output: 'jsonlogs' }, cypress-cucumber-preprocessor html: { enabled: false, output: 'cucumber-report.html' }, cypress-cucumber-preprocessor pretty: { enabled: false }, cypress-cucumber-preprocessor filterSpecsMixedMode: 'hide', cypress-cucumber-preprocessor filterSpecs: false, cypress-cucumber-preprocessor omitFiltered: false, cypress-cucumber-preprocessor implicitIntegrationFolder: '/Users/pavgurra/Desktop/Apps/Admiral/repo/ui-admiralmoney-public/apps/host-e2e/src/integration/e2e/upl', cypress-cucumber-preprocessor isTrackingState: true cypress-cucumber-preprocessor } +0ms cypress-cucumber-preprocessor resolving step definitions using template(s) [ './apps/host-e2e/src/support/step_definitions/.js' ] +0ms cypress-cucumber-preprocessor replacing [filepath] with 'upl-e2e-journeys' +0ms cypress-cucumber-preprocessor replacing [filepart] with [ 'upl-e2e-journeys' ] +0ms cypress-cucumber-preprocessor for 'apps/host-e2e/src/integration/e2e/upl/upl-e2e-journeys.feature' yielded patterns [ 'apps/host-e2e/src/support/step_definitions/.js' ] +1ms cypress-cucumber-preprocessor found step definitions [ cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_partner.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_motor_pos.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_motor.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_mock_quote.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_mock_motor.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_mock_hub.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_mock_help.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_mock_auth.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_mock_app.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_mock.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_manual.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_independent.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_halo.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_common.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_accessibility.js', cypress-cucumber-preprocessor 'apps/host-e2e/src/support/step_definitions/steps_UPL.js' cypress-cucumber-preprocessor ] +4ms

End to End Regression Test Scenarios cypress-cucumber-preprocessor specEnvelopesHandler() +4s cypress-cucumber-preprocessor testCaseStartedHandler() +9ms cypress-cucumber-preprocessor testStepStartedHandler() +6ms cypress-cucumber-preprocessor testStepFinishedHandler() +70ms cypress-cucumber-preprocessor testCaseFinishedHandler() +6ms ✓ Test - UPL Journey (154ms)

1 passing (215ms)

cypress-cucumber-preprocessor afterSpecHandler() +17ms

(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Tests: 1 │ │ Passing: 1 │ │ Failing: 0 │ │ Pending: 0 │ │ Skipped: 0 │ │ Screenshots: 0 │ │ Video: false │ │ Duration: 0 seconds │ │ Spec Ran: upl-e2e-journeys.feature │ └────────────────────────────────────────────────────────────────────────────────────────────────┘

====================================================================================================

(Run Finished)

   Spec                                              Tests  Passing  Failing  Pending  Skipped  

┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ ✔ upl-e2e-journeys.feature 217ms 1 1 - - - │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ ✔ All specs passed! 217ms 1 1 - - -

PavanGurram-DevOps avatar Aug 30 '24 05:08 PavanGurram-DevOps

Hi @PavanGurram-DevOps, I recommend that you use the latest version of @badeball/cypress-cucumber-preprocessor, for which the external cucumber-json-formatter is no longer necessary.

badeball avatar Aug 30 '24 14:08 badeball

Thanks @badeball for the response.

I have resolved it just now. The issue is not with the version, it is with multiple plugins in cypress.config.js file and I ahve seen one more closed ticket which mentions to use cypress-on-fix library.

It would have been easier and time saving if this is mentioned in the documentation itslef so that it would have saved many hours of mine :)

But thats fine, the solution worked which is what needed.

Thanks again for your nice work :)

PavanGurram-DevOps avatar Aug 30 '24 14:08 PavanGurram-DevOps

It would have been easier and time saving if this is mentioned in the documentation itslef so that it would have saved many hours of mine :)

This is mentioned in the FAQ and there's a whole page dedicated to this very problem.

badeball avatar Aug 30 '24 14:08 badeball

Many thanks @badeball . You are awesome :)

PavanGurram-DevOps avatar Aug 30 '24 14:08 PavanGurram-DevOps