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

Test names aren't output when logging to file; test contexts aren't output at all #70

Closed
unikitty37 opened this issue Dec 19, 2020 · 1 comment
Assignees

Comments

@unikitty37
Copy link

I'm using cypress-terminal-report 2.4.0 with Cypress 5.6.0 in GitLab CI, using this config:

  require('cypress-terminal-report/src/installLogsPrinter')(on, {
    printLogsToConsole: 'onFail',
    printLogsToFile: 'always',
    outputRoot: `${ config.projectRoot }/.cypress_logs/`,
    specRoot: path.relative(config.fileServerFolder, config.integrationFolder),
    outputTarget: {
      'cypress-logs|txt': 'txt',
    },
  })

and this test:

  context('when editing or creating an issue', () => {
    context('when the user is logged out', () => {
      context('when editing the issue', () => {
        it('tells the user they must log in', () => {
          // test goes here
        })
      })
    })
  })

Logs printed to file partially identify the test being run, showing the name of the test but not the names of any containing context() blocks:

tests/e2e/integration/issue_form_spec.js:
    tells the user they must log in
        cy:request (K): http://backend:3000/api/v1/rails/reset_db
                        Status: 200
                        Response body: {
                          "errors": []
                        }

But logs printed to console don't give any identification at all:

cypress_1   |   Running:  issue_form_spec.js                                                         (7 of 15)
cypress_1   |       cy:request ✔  http://backend:3000/api/v1/rails/reset_db
cypress_1   |                     Status: 200
cypress_1   |                     Response body: {
cypress_1   |                       "errors": []
cypress_1   |                     }

This makes it difficult to find which test a log relates to, unless every test starts with a cy.log() statement giving its name, which clutters the test files unnecessarily. Would it be possible to have the name of the test output to console as well as to file, and context names output as well as test names in both cases?

(Now that I think about it, it may be a difference between onFail and always rather than logging to console vs logging to file… I've also just noticed that the tick emoji has been changed to a K when outputting to file — is that intentional?)

@archfz archfz self-assigned this Feb 26, 2021
@archfz
Copy link
Owner

archfz commented Mar 9, 2021

Released in 3.0.0.

@archfz archfz closed this as completed Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants