cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.03k stars 3.19k forks source link

3.8.0 run report has puzzling 'undefined' lines #5995

Closed PetMou closed 4 years ago

PetMou commented 4 years ago

When I do a 'cypress run' (windows 10 environment), I get several lines with text 'undefined' in the report. To exclude any local influences, I made a dummy scenario which does absolutely nothing, with a minimal 'cypress.json' file. But still it reports these lines.


  Running:  dummy.spec.js                                                                   (1 of 1)
undefined

  dummy describe
    √ dummy it (85ms)
undefined
undefined
  1 passing (96ms)
undefined

  (Results)

All tests pass, so it is not blocking. It's just puzzling. Running in debug mode gives no clues as to what is undefined:



 2019-12-18T09:00:40.155Z cypress:server:project onMocha pass
 2019-12-18T09:00:40.155Z cypress:server:reporter got mocha event 'pass' with args: [ { id: 'r3', title: 'dummy it', state: 'passed', body: 'function () {// nothing happens\n  }', type: 'test', duration: 15, wallClockStartedAt: '2019-12-18T09:00:40.145Z', timings: { lifecycle: 14, test: [Object] } } ]

     √ dummy it
 2019-12-18T09:00:40.155Z cypress:server:project onMocha test end
 2019-12-18T09:00:40.155Z cypress:server:reporter got mocha event 'test end' with args: [ { id: 'r3', title: 'dummy it', state: 'passed', body: 'function () {// nothing happens\n  }', type: 'test', duration: 15, wallClockStartedAt: '2019-12-18T09:00:40.145Z', timings: { lifecycle: 14, test: [Object] } } ]
 2019-12-18T09:00:40.169Z cypress:server:project onMocha test:after:run
 2019-12-18T09:00:40.169Z cypress:server:reporter got mocha event 'test:after:run' with args: [ { id: 'r3', title: 'dummy it', state: 'passed', body: 'function () {// nothing happens\n  }', type: 'test', duration: 15, wallClockStartedAt: '2019-12-18T09:00:40.145Z', wallClockDuration: 19, timings: { lifecycle: 14, test: [Object] } } ]
 2019-12-18T09:00:40.170Z cypress:server:project onMocha suite end
 2019-12-18T09:00:40.170Z cypress:server:reporter got mocha event 'suite end' with args: [ { id: 'r2', title: 'dummy describe', root: false, type: 'suite' } ]
undefined
 2019-12-18T09:00:40.171Z cypress:server:project onMocha suite end
 2019-12-18T09:00:40.171Z cypress:server:reporter got mocha event 'suite end' with args: [ { id: 'r1', title: '', root: true, type: 'suite' } ]
 2019-12-18T09:00:40.171Z cypress:server:project onMocha end
 2019-12-18T09:00:40.171Z cypress:server:reporter got mocha event 'end' with args: [ { end: '2019-12-18T09:00:40.167Z' } ]
 undefined
   1 passing (38ms)
 undefined

   (Results)

   ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
   │ Tests:        1                                                                                │
   │ Passing:      1                                                                                │
   │ Failing:      0                                                                                │
   │ Pending:      0                                                                                │
   │ Skipped:      0                                                                                │
   │ Screenshots:  0                                                                                │
   │ Video:        true                                                                             │
   │ Duration:     0 seconds                                                                        │
   │ Spec Ran:     dummy.spec.js                                                                    │
   └────────────────────────────────────────────────────────────────────────────────────────────────┘

 2019-12-18T09:00:41.178Z cypress:server:run attempting to close the browser

>
syedmuhdahmad commented 4 years ago

@PetMou I am also facing the same issue on Windows 10 any luck finding solution

jennifer-shehane commented 4 years ago

@PetMou Can you provide a small repo where when run where this is happening in Windows 10? Thanks.

PetMou commented 4 years ago

Hereby the minimal scenario that shows the issue. I hope this is enough? cypress_5995.zip

These 'undefined' lines do not show up in our (Linux) pipeline, nor in a headed run. We use Windows 10 Enterprise in a HyperV environment. cypress.json:

{
  "chromeWebSecurity": false,
  "video": false,
  "integrationFolder": "cypress/integration"
}
irfancharania commented 4 years ago

I'm experiencing this same issue in our Windows Server 2016 Standard environment in a headless run with 3.8.0 and 3.8.1

tmc101 commented 4 years ago

Seeing the same thing with 3.8.2 - this doesn't happen with 3.7.0.

To reproduce in an empty folder:

npm init -y

npm install cypress --save-dev

npx cypress open

npx cypress run

image

jennifer-shehane commented 4 years ago

I was able to track this down in our own Appveyor runs on Windows of our kitchen-sink.

3.7.0

Appveyor build: https://ci.appveyor.com/project/cypress-io/cypress-example-kitchensink/builds/29572107

Screen Shot 2020-01-14 at 1 59 50 PM

3.8.0

Appveyor build: https://ci.appveyor.com/project/cypress-io/cypress-example-kitchensink/builds/29572107

Screen Shot 2020-01-14 at 2 00 01 PM
jennifer-shehane commented 4 years ago

Is this reproducible when running cypress run --browser chrome?

jennifer-shehane commented 4 years ago

I've been looking through the PRs in 3.8.0, there are some that touch the run.js file that issues the output here, but I don't see anything that should have affected the output.

There is also this Windows specific PR that went into 3.8.0 https://github.com/cypress-io/cypress/pull/5853

dwelle commented 4 years ago

Is this reproducible when running cypress run --browser chrome?

Yes

piksel commented 4 years ago

Same behaviour on v4.0.1

This is due to how console.log works in electron on windows: (lib/browser/init.ts:18)

  // Redirect node's console to use our own implementations, since node can not
  // handle console output when running as GUI program.
  const consoleLog = (format: any, ...args: any[]) => {
    return process.log(util.format(format, ...args) + '\n')
  }

Which means that every time that mocha wants to output an empty row, through console.log(), this happens:

let consoleLog = (format, ...args) => util.format(format, ...args); 
consoleLog(); // 'undefined'

The change in electron happened here: https://github.com/electron/electron/pull/16441/files#diff-fd84dda09f0dbd7e74e2822ff6cf19a8R27 But I have not figured out what version that was released in.

bahmutov commented 4 years ago

nice @piksel - thanks for this. Is there an issue in Electron repo for this behavior by any chance? @flotwig can we stub console.log() and call console.log('') to get around this?

piksel commented 4 years ago

I haven't been able to find any issues for it in electron. I'll make one.

The temporary fix I did was to put this in server/index.js:

const consoleLog = console.log;
console.log = (...args) => consoleLog(...(args.length<1?['']:args));
PetMou commented 4 years ago

I hope this doesn't alter the root cause found by @piksel, but the issue also appears when running with headless chrome options...

piksel commented 4 years ago

No, it still applies. Regardless of what browser you are using, the "orchestrator" is always Cypress.exe (or the OS binary equivalent) which is a branded electron binary.

On Mon, 10 Feb 2020 at 13:47, PetMou notifications@github.com wrote:

I hope this doesn't alter the root cause found by @piksel https://github.com/piksel, but the issue also appears when running with headless chrome options...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cypress-io/cypress/issues/5995?email_source=notifications&email_token=AAGFDVZYSH4G456K5642IYDRCFEFNA5CNFSM4J4IBVHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELIL6OA#issuecomment-584105784, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGFDV7MQ7MEUPV5GWJGJPLRCFEFNANCNFSM4J4IBVHA .

PetMou commented 4 years ago

Fixed in 4.1.0 ! Closing the issue

flotwig commented 4 years ago

This was fixed because Electron was bumped from 7.1.10 to 7.1.13 in Cypress 4.1.0, and this bug was fixed in 7.1.13: https://github.com/electron/electron/pull/22173

jennifer-shehane commented 4 years ago

This issue will be closed to further comment as the exact issue here was resolved and tested.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.