Skip to content
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

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

Open
adinizs opened this issue Aug 1, 2022 · 21 comments

Comments

@adinizs
Copy link

adinizs commented Aug 1, 2022

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}"
]
}

@AfganSh
Copy link

AfganSh commented Aug 14, 2022

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

@radhakrishnanakireddy
Copy link

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!

@badeball
Copy link
Member

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.

@radhakrishnanakireddy
Copy link

@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!

@ashort-zaizi
Copy link

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.

@a8trejo
Copy link

a8trejo commented Aug 25, 2022

@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

@ashort-zaizi
Copy link

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

@adinizs
Copy link
Author

adinizs commented Aug 26, 2022

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

@a8trejo
Copy link

a8trejo commented Aug 26, 2022

@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
Copy link

a8trejo commented Aug 26, 2022

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

@adinizs
Copy link
Author

adinizs commented Aug 26, 2022

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

@a8trejo
Copy link

a8trejo commented Aug 26, 2022

@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
Copy link

a8trejo commented Aug 26, 2022

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

@adinizs
Copy link
Author

adinizs commented Aug 26, 2022

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 !!

@a8trejo
Copy link

a8trejo commented Aug 26, 2022

happy to help! :D

@radhakrishnanakireddy
Copy link

@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!

@ashort-zaizi
Copy link

ashort-zaizi commented Sep 4, 2022

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!

@LPalomeque99
Copy link

LPalomeque99 commented Dec 12, 2022

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

@a8trejo
Copy link

a8trejo commented Dec 13, 2022

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

@KShewengger
Copy link

KShewengger commented Mar 21, 2023

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

@w4dd325
Copy link

w4dd325 commented Mar 31, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants