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

Not generating JSON reports after each run #851

Closed
3 tasks done
jaxfellow opened this issue Oct 6, 2022 · 19 comments
Closed
3 tasks done

Not generating JSON reports after each run #851

jaxfellow opened this issue Oct 6, 2022 · 19 comments

Comments

@jaxfellow
Copy link

I've been using the cypress-cucumber-preprocessor v4.3.1 and my implementation was in cypress/plugin/index.ts file like:

const cucumber = require('cypress-cucumber-preprocessor').default

module.exports = (on, config) => {
  on('file:preprocessor', cucumber())
}

and my package.json file was like

"cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true,
    "cucumberJson": {
      "generate": true,
      "outputFolder": "cypress/cucumber-json",
      "filePrefix": "",
      "fileSuffix": ".cucumber"
    }
  }

which was generating json files that I'm using later in multiple-cucumber-html-reporter to generate a nice report.

After migrating to Cypress 10 and using @badeball/cypress-cucumber-preprocessor v13.0.2 I have no json file generated anymore! I've followed the examples here

It is mentioned in the example:

  // This is required for the preprocessor to be able to generate JSON reports after each run, and more,
  await addCucumberPreprocessorPlugin(on, config);

but I'm not getting any, am I missing anything?

Checklist

  • I've read the FAQ.
  • I've read Instructions for logging issues.
  • I'm not using cypress-cucumber-preprocessor@4.3.1 (package name has changed and it is no longer the most recent version, see #689).
@badeball
Copy link
Owner

badeball commented Oct 6, 2022

@jaxfellow
Copy link
Author

well, my package.json was:

"cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true,
    "cucumberJson": {
      "generate": true,
      "outputFolder": "cypress/cucumber-json",
      "filePrefix": "",
      "fileSuffix": ".cucumber"
    }
  }

and I tried to change

"cucumberJson": {
      "generate": true,

to this but it didn't work

  "json": {
    "enabled": true
  }

@badeball
Copy link
Owner

badeball commented Oct 6, 2022

Run with DEBUG=cypress:electron,cypress-configuration,cypress-cucumber-preprocessor, as explained in the above-mentioned link and paste the output.

@jaxfellow
Copy link
Author

it created cucumber-messages.ndjson file with encoded content.

@sszemer
Copy link

sszemer commented Oct 21, 2022

Run with DEBUG=cypress:electron,cypress-configuration,cypress-cucumber-preprocessor, as explained in the above-mentioned link and paste the output.

i have a simillar issue, but i get no results from this command.
packages.json

{
  "devDependencies": {
    "@bahmutov/cypress-esbuild-preprocessor": "^2.1.5",
    "@typescript-eslint/eslint-plugin": "^5.39.0",
    "@typescript-eslint/parser": "^5.39.0",
    "cypress": "^10.10.0",
    "esbuild": "^0.15.9",
    "eslint": "^8.24.0",
    "typescript": "^4.8.4"
  },
  "dependencies": {
    "@badeball/cypress-cucumber-preprocessor": "^13.0.2",
    "cypress-xpath": "^2.0.1",
    "prettier": "^2.7.1",
    "cypress-cucumber-preprocessor": {
      "json": {
        "enabled": true
      }
    }
  },

cypress.config.ts

import { defineConfig } from 'cypress';
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor');
const addCucumberPreprocessorPlugin =
	require('@badeball/cypress-cucumber-preprocessor').addCucumberPreprocessorPlugin;
const createEsbuildPlugin =
	require('@badeball/cypress-cucumber-preprocessor/esbuild').createEsbuildPlugin;

export default defineConfig({
	retries: {
		runMode: 1,
		openMode: 0,
	},
	video: false,
	videoCompression: 33,
	defaultCommandTimeout: 5000,
	chromeWebSecurity: false,
	watchForFileChanges: false,
	viewportWidth: 1280,
	viewportHeight: 720,
	execTimeout: 60000,
	pageLoadTimeout: 60000,
	requestTimeout: 15000,
	responseTimeout: 15000,
	e2e: {
		async setupNodeEvents(on, config){
			await addCucumberPreprocessorPlugin(on, config);
			on('file:preprocessor', createBundler({
				plugins: [createEsbuildPlugin(config)],
			}));
			return config;
		},
		specPattern: 'cypress/e2e/features/*.feature',
	},
});

@badeball
Copy link
Owner

The above-mentioned variable makes Cypress output more to stdout, It's this output I'm looking for.

@clupascu-sudo
Copy link

clupascu-sudo commented Oct 21, 2022

@badeball I think we need a different solution to the cucumber-json-formatter that is required. This is because this library should be platform independent - for example, I'm on a mac but I also need this json report to publish as part of an azure pipeline build.

Could you possibly move away from this cucumber-json-formatter to something else? This is currently stopping my team from upgrading to cypress 10.

@badeball
Copy link
Owner

for example, I'm on a mac but I also need this json report to publish as part of an azure pipeline build.

You're not making any sense to me here. How is this not possible?

@clupascu-sudo
Copy link

I don't want platform-specific installation guides depending on where I'm coding from.
this is not platform independent. I want to be able to do:

  • npm install
  • cypress run
  • and for it to work without any other steps. As with cypress versions < 10

@badeball
Copy link
Owner

I understand that that's a preference, but not how it's stopping you.

@clupascu-sudo
Copy link

Well, it's stopping us because I don't want any additional steps in my sldc.
We have devs on windows, macs, pipelines that just run cypress, and pipelines that run cypress inside a docker container. (never mind the fact that I can't seem to find a docker image of this formatter - which also would need to be platform specific I assume)
Now if I can't:

  • run the same dockerfile locally as in my azure pipeline
  • run the same npm commands locally as in my azure pipeline
    then I won't upgrade my cypress version, it's ruining the development experience by creating additional steps.

@badeball
Copy link
Owner

I'm only reading laziness and entitlement here, because all of the above appears trivial. You're already running platform-dependent software, such as node. I'll have you know despite this, that I am considering alternatives, but not because of anything you describe.

@clupascu-sudo
Copy link

clupascu-sudo commented Oct 21, 2022

haha ok, well I hope you change it - not sure how I could make more sense but oh well. Sure, node/nvm is platform dependent, but not anything else.

Anyway, thanks and Happy Friday!

@clupascu-sudo
Copy link

clupascu-sudo commented Oct 21, 2022

Folks, for those of you having an issue due to the cucumber-json-formatter - I managed to use this cucumber preprocessor instead. This doesn't have any pre-requirements (setup is also more similar to what we had with cypress versions < 10 - not necessarily a good thing)

@jaxfellow
Copy link
Author

thanks @clupascu-sudo, did it generate json file for you? cause it didn't work for me either.

@clupascu-sudo
Copy link

clupascu-sudo commented Oct 24, 2022

The other plugin did, yep! @jaxfellow

@mysticdevx
Copy link

Hey, was having the same issue with cypress-cucumber-preprocessor, while the allure-reports plugin here was active, but then this issue resolved my problem and now all is ok.

@MassimoLobrutto
Copy link

https://socket.dev/npm/package/@deepakvishwakarma/cucumber-json-formatter this library automatically checks the platform and uses the relevant cucumber-json-formatter. No messing around with exes. Download the library, configure in package.json and away you go

@badeball
Copy link
Owner

Closing due to lack of a reproducible example.

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

6 participants