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

Enable possibility to generate cucumber.json with dynamic prefix #1055

Closed
elena-altuhova opened this issue Jul 11, 2023 · 4 comments
Closed

Comments

@elena-altuhova
Copy link

Current behavior

Currently it's possible to set desired alternative static cucumber.json name/path with json.output property

Desired behavior

Hello @badeball! What do you think about possibility to parametrize json.output property a little bit more? It would be really useful to have a possibility to set 'unique' (ex. timestamp or feature name) name for this json to avoid overwriting test results in some cases

Checklist

  • [ x] I've read the FAQ.
  • [x ] I've read instructions for logging issues.
  • [ x] 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 Jul 11, 2023

Hi @elena-altuhova. I'm not opposed to the idea, but can you ellaborate a bit more on the "some cases" in which this would be "really useful"?

@elena-altuhova
Copy link
Author

elena-altuhova commented Jul 11, 2023

So our current case, which basically was the reason of this suggestion, is that with an attempt to upgrade to latest Cypress version (from 10 to 12+) we switched from cy2 to cypress-cloud for parallel runs.
After switching we have noticed that cypress-cloud orchestrates the parallel run in such a manner, where it gives a command to execute one feature separately and only after it finishes - another feature and so on. (native orchestration diagram describes it here)
So when it happens - cucumber.json gets overwritten and at the end of the run we have only last feature results in there. Having possibility to have unique names for cucumber.json for each executed feature would solve this problem for us.
Thanks a lot for considering this.

@badeball
Copy link
Owner

I'm not so sure that this requires any change from the library side. You can configure a dynamic output path during runtime, like shown below.

const { defineConfig } = require("cypress");
const { cloudPlugin } = require("cypress-cloud/plugin");

module.exports = defineConfig({
  e2e: {
    async setupNodeEvents(cypressOn, config) {
      const on = require("cypress-on-fix")(cypressOn);

      if (config.projectId) {
        config.env["jsonOutput"] = `cucumber-report-${new Date().getTime()}.json`;
      }

      await addCucumberPreprocessorPlugin(on, config);

      on(
        "file:preprocessor",
        createBundler({
          plugins: [createEsbuildPlugin(config)],
        })
      );

      return cloudPlugin(on, config);
    },
  },
});

@elena-altuhova
Copy link
Author

Just tried it and it works! Thanks a lot for your help! 🥇

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

2 participants