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

After hook crashes if log files exist #57

Closed
csvan opened this issue Nov 9, 2020 · 3 comments
Closed

After hook crashes if log files exist #57

csvan opened this issue Nov 9, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@csvan
Copy link

csvan commented Nov 9, 2020

The following code in BaseOutputProcessor.js:

hasSpecChunkWritten(spec) {
    return !!this.specChunksWritten[spec];
}

will throw if a log file for the current spec already exists in the output folder. This is because the following doesn't get invoked:

if (!fs.existsSync(this.file)) {
  this.prepareForWrite();
}

Due to this, this.specChunksWritten is never initialized before hasSpecChunkWritten tries to access it.

@archfz
Copy link
Owner

archfz commented Nov 9, 2020

Do you have steps to reproduce so we can write a test for this case?

@csvan
Copy link
Author

csvan commented Nov 9, 2020

  1. Add a standard Cypress setup with at least one spec file - integration/myTest.spec.js
  2. Add to plugins:
  require('cypress-terminal-report/src/installLogsPrinter')(on, {
    outputRoot: 'cypress/',
    specRoot: 'cypress/integration',
    printLogsToFile: 'always', // <--- so that we always try to access the file
    printLogsToConsole: 'never',
    outputTarget: {
      'logs|txt': 'txt',
      'logs|json': 'json',
    },
  });

Add to support:

require('cypress-terminal-report/src/installLogsCollector')();
  1. add myTest.txt to cypress/logs

  2. run cypress

@archfz archfz added the bug Something isn't working label Nov 18, 2020
@archfz
Copy link
Owner

archfz commented Nov 28, 2020

Released in 2.3.1

@archfz archfz closed this as completed Nov 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants