cypress-terminal-report icon indicating copy to clipboard operation
cypress-terminal-report copied to clipboard

Not working when cypress run

Open andrewaldasoro opened this issue 1 year ago • 9 comments

When we use outputTarget: cypress-log.json the file is being created but it overwrites it in between every test. If we use outputTarget: cypress-log|json the file is not being created

We have some some scripts to run cypress in our package.json

{
 "cypress:open": "cypress open",
  "cypress:run": "cypress run",
} 

with cypress:open the directory form it's working fine, but not with cypress:run

andrewaldasoro avatar Aug 04 '22 17:08 andrewaldasoro

The configuration:

const options = {
    outputRoot: config.projectRoot + "/logs/",
    specRoot: "cypress/e2e",
    outputTarget: {
      "cypress-logs|json": "json",
    },
    printLogsToFile: "always",
    printLogsToConsole: "onFail",
  };
  require("cypress-terminal-report/src/installLogsPrinter")(on, options);

andrewaldasoro avatar Aug 04 '22 18:08 andrewaldasoro

Please also post the version of the plugin and of cypress.

archfz avatar Aug 05 '22 14:08 archfz

4.1.1

andrewaldasoro avatar Aug 05 '22 17:08 andrewaldasoro

And cypress version?

archfz avatar Aug 05 '22 17:08 archfz

10.3.1

andrewaldasoro avatar Aug 05 '22 17:08 andrewaldasoro

I cannot reproduce this issue. Both single file output and nested outputs work correctly.

Maybe more details could help, like what browser are the tests running in? is it reproducing locally and in pipelines as well? do you use any other plugins? what are your support install options? or can you maybe provide a reproducible setup (issue repo link)?

If you know how to use the nodejs debugger you could also do your own investigation: starting with a breakpoint here https://github.com/archfz/cypress-terminal-report/blob/master/src/installLogsPrinter.js#L107

archfz avatar Aug 05 '22 18:08 archfz

Browser : chrome Reproducing locally as well as in pipelines. We are using cypress-grep plugin too. Plugin configuration in support/e2e.ts:

import registerCypressGrep from "cypress-grep";
import registerCypressLogCollector, {
  SupportOptions,
} from "cypress-terminal-report/src/installLogsCollector";
registerCypressGrep();
const options: SupportOptions = {
  collectTypes: ["cy:log", "cy:command"],
  enableContinuousLogging: false,
  enableExtendedCollector: false,
  debug: false,
};
registerCypressLogCollector(options);

harithavupputuru avatar Aug 08 '22 12:08 harithavupputuru

@harithavupputuru There must be something else going on. I have attempted unsuccessfully to reproduce based on the options from the comments, using chrome (Ubuntu). See here https://github.com/archfz/cypress-terminal-report-demo/pull/6/files

Can you check if it is working correctly for you on that branch? Maybe report back if you seem some critical difference in configuration.

archfz avatar Aug 08 '22 20:08 archfz

With above configuration: Logs generated for command -> cypress run configFile=smoke --browser chrome Log not generated for command -> cypress run --env grepTags="smoke" configFile=smoke --browser chrome

harithavupputuru avatar Aug 09 '22 20:08 harithavupputuru

Fix released in 4.1.2

archfz avatar Aug 12 '22 20:08 archfz