Skip to content

Commit

Permalink
fix: junit reporters crashing on failed asserts (#24677)
Browse files Browse the repository at this point in the history
* fix: junit reporters crashing on failures

* handle other platforms

* Fix system tests

* fix snapshot

* fix snapshot

* fix snapshot
  • Loading branch information
ryanthemanuel committed Nov 14, 2022
1 parent 90d0003 commit 9b1d05d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 21 deletions.
45 changes: 41 additions & 4 deletions system-tests/__snapshots__/reporters_spec.js
Expand Up @@ -9,6 +9,8 @@ We searched for the reporter in these paths:
Learn more at https://on.cypress.io/reporters
Error: Cannot find module '/foo/bar/.projects/e2e/node_modules/module-does-not-exist'
Require stack:
- lib/reporter.js
[stack trace lines]
`

Expand All @@ -21,14 +23,14 @@ exports['e2e reporters supports junit reporter and reporter options 1'] = `
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (simple_passing.cy.js)
│ Searched: cypress/e2e/simple_passing.cy.js
│ Specs: 2 found (simple_passing.cy.js, simple_failing.cy.js)
│ Searched: cypress/e2e/simple_passing.cy.js, cypress/e2e/simple_failing.cy.js
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: simple_passing.cy.js (1 of 1)
Running: simple_passing.cy.js (1 of 2)
(Results)
Expand All @@ -51,6 +53,39 @@ exports['e2e reporters supports junit reporter and reporter options 1'] = `
- Finished processing: /XXX/XXX/XXX/cypress/videos/simple_passing.cy.js.mp4 (X second)
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: simple_failing.cy.js (2 of 2)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 2 │
│ Passing: 0 │
│ Failing: 2 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 2 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: simple_failing.cy.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Screenshots)
- /XXX/XXX/XXX/cypress/screenshots/simple_failing.cy.js/simple failing spec -- fai (1280x720)
ls1 (failed).png
- /XXX/XXX/XXX/cypress/screenshots/simple_failing.cy.js/simple failing spec -- fai (1280x720)
ls2 (failed).png
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/simple_failing.cy.js.mp4 (X second)
====================================================================================================
(Run Finished)
Expand All @@ -59,8 +94,10 @@ exports['e2e reporters supports junit reporter and reporter options 1'] = `
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ simple_passing.cy.js XX:XX 1 1 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ✖ simple_failing.cy.js XX:XX 2 - 2 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 1 1 - - -
✖ 1 of 2 failed (50%) XX:XX 3 1 2 - -
`
Expand Down
18 changes: 13 additions & 5 deletions system-tests/test/reporters_spec.js
Expand Up @@ -36,22 +36,30 @@ describe('e2e reporters', () => {

it('supports junit reporter and reporter options', function () {
return systemTests.exec(this, {
spec: 'simple_passing.cy.js',
spec: 'simple_passing.cy.js,simple_failing.cy.js',
snapshot: true,
reporter: 'junit',
reporterOptions: 'mochaFile=junit-output/result.[hash].xml,testCaseSwitchClassnameAndName=true',
expectedExitCode: 2,
})
.then(() => {
return glob(path.join(e2ePath, 'junit-output', 'result.*.xml'))
.then((paths) => {
expect(paths.length).to.eq(1)
expect(paths.length).to.eq(2)

return Promise.all([fs.readFileAsync(paths[0], 'utf8'), fs.readFileAsync(paths[1], 'utf8')])
.then((results) => {
const str = results.join('')

return fs.readFileAsync(paths[0], 'utf8')
.then((str) => {
expect(str).to.include('<testsuite name="simple passing spec"')
expect(str).to.include('<testcase name="passes"')

expect(str).to.include('classname="simple passing spec passes"')

expect(str).to.include('<testsuite name="simple failing spec"')
expect(str).to.include('<testcase name="fails1"')
expect(str).to.include('<testcase name="fails2"')
expect(str).to.include('classname="simple failing spec fails1"')
expect(str).to.include('classname="simple failing spec fails2"')
})
})
})
Expand Down
Expand Up @@ -50,12 +50,16 @@
"./packages/https-proxy/lib/ca.js",
"./packages/net-stubbing/node_modules/debug/src/node.js",
"./packages/network/node_modules/minimatch/minimatch.js",
"./packages/server/lib/browsers/utils.ts",
"./packages/server/lib/capture.js",
"./packages/server/lib/cloud/exception.ts",
"./packages/server/lib/errors.ts",
"./packages/server/lib/modes/record.js",
"./packages/server/lib/modes/run.ts",
"./packages/server/lib/open_project.ts",
"./packages/server/lib/project-base.ts",
"./packages/server/lib/socket-ct.ts",
"./packages/server/lib/util/process_profiler.ts",
"./packages/server/lib/util/suppress_warnings.js",
"./packages/server/node_modules/@benmalka/foxdriver/node_modules/graceful-fs/polyfills.js",
"./packages/server/node_modules/glob/node_modules/minimatch/minimatch.js",
Expand Down Expand Up @@ -825,20 +829,17 @@
"./packages/server/lib/browsers/firefox-util.ts",
"./packages/server/lib/browsers/firefox.ts",
"./packages/server/lib/browsers/index.ts",
"./packages/server/lib/browsers/utils.ts",
"./packages/server/lib/browsers/webkit-automation.ts",
"./packages/server/lib/browsers/webkit.ts",
"./packages/server/lib/cache.js",
"./packages/server/lib/cloud/api.ts",
"./packages/server/lib/cloud/auth.ts",
"./packages/server/lib/cloud/exception.ts",
"./packages/server/lib/cloud/routes.ts",
"./packages/server/lib/cloud/user.ts",
"./packages/server/lib/config.ts",
"./packages/server/lib/controllers/iframes.ts",
"./packages/server/lib/cypress.js",
"./packages/server/lib/environment.js",
"./packages/server/lib/errors.ts",
"./packages/server/lib/gui/windows.ts",
"./packages/server/lib/log.js",
"./packages/server/lib/makeDataContext.ts",
Expand Down Expand Up @@ -869,7 +870,6 @@
"./packages/server/lib/util/file-opener.ts",
"./packages/server/lib/util/fs.ts",
"./packages/server/lib/util/glob.js",
"./packages/server/lib/util/process_profiler.ts",
"./packages/server/lib/util/proxy.ts",
"./packages/server/lib/util/resourceTypeAndCredentialManager.ts",
"./packages/server/lib/util/socket_allowed.ts",
Expand Down
8 changes: 4 additions & 4 deletions tooling/v8-snapshot/cache/prod-linux/snapshot-meta.cache.json
Expand Up @@ -50,10 +50,14 @@
"./packages/https-proxy/lib/ca.js",
"./packages/net-stubbing/node_modules/debug/src/node.js",
"./packages/network/node_modules/minimatch/minimatch.js",
"./packages/server/lib/browsers/utils.ts",
"./packages/server/lib/capture.js",
"./packages/server/lib/cloud/exception.ts",
"./packages/server/lib/errors.ts",
"./packages/server/lib/modes/record.js",
"./packages/server/lib/modes/run.ts",
"./packages/server/lib/open_project.ts",
"./packages/server/lib/util/process_profiler.ts",
"./packages/server/lib/project-base.ts",
"./packages/server/lib/socket-ct.ts",
"./packages/server/lib/util/suppress_warnings.js",
Expand Down Expand Up @@ -824,20 +828,17 @@
"./packages/server/lib/browsers/firefox-util.ts",
"./packages/server/lib/browsers/firefox.ts",
"./packages/server/lib/browsers/index.ts",
"./packages/server/lib/browsers/utils.ts",
"./packages/server/lib/browsers/webkit-automation.ts",
"./packages/server/lib/browsers/webkit.ts",
"./packages/server/lib/cache.js",
"./packages/server/lib/cloud/api.ts",
"./packages/server/lib/cloud/auth.ts",
"./packages/server/lib/cloud/exception.ts",
"./packages/server/lib/cloud/routes.ts",
"./packages/server/lib/cloud/user.ts",
"./packages/server/lib/config.ts",
"./packages/server/lib/controllers/iframes.ts",
"./packages/server/lib/cypress.js",
"./packages/server/lib/environment.js",
"./packages/server/lib/errors.ts",
"./packages/server/lib/gui/windows.ts",
"./packages/server/lib/log.js",
"./packages/server/lib/makeDataContext.ts",
Expand Down Expand Up @@ -868,7 +869,6 @@
"./packages/server/lib/util/file-opener.ts",
"./packages/server/lib/util/fs.ts",
"./packages/server/lib/util/glob.js",
"./packages/server/lib/util/process_profiler.ts",
"./packages/server/lib/util/proxy.ts",
"./packages/server/lib/util/resourceTypeAndCredentialManager.ts",
"./packages/server/lib/util/socket_allowed.ts",
Expand Down
8 changes: 4 additions & 4 deletions tooling/v8-snapshot/cache/prod-win32/snapshot-meta.cache.json
Expand Up @@ -50,10 +50,14 @@
"./packages/https-proxy/lib/ca.js",
"./packages/net-stubbing/node_modules/debug/src/node.js",
"./packages/network/node_modules/minimatch/minimatch.js",
"./packages/server/lib/browsers/utils.ts",
"./packages/server/lib/capture.js",
"./packages/server/lib/cloud/exception.ts",
"./packages/server/lib/errors.ts",
"./packages/server/lib/modes/record.js",
"./packages/server/lib/modes/run.ts",
"./packages/server/lib/open_project.ts",
"./packages/server/lib/util/process_profiler.ts",
"./packages/server/lib/project-base.ts",
"./packages/server/lib/socket-ct.ts",
"./packages/server/lib/util/suppress_warnings.js",
Expand Down Expand Up @@ -827,20 +831,17 @@
"./packages/server/lib/browsers/firefox-util.ts",
"./packages/server/lib/browsers/firefox.ts",
"./packages/server/lib/browsers/index.ts",
"./packages/server/lib/browsers/utils.ts",
"./packages/server/lib/browsers/webkit-automation.ts",
"./packages/server/lib/browsers/webkit.ts",
"./packages/server/lib/cache.js",
"./packages/server/lib/cloud/api.ts",
"./packages/server/lib/cloud/auth.ts",
"./packages/server/lib/cloud/exception.ts",
"./packages/server/lib/cloud/routes.ts",
"./packages/server/lib/cloud/user.ts",
"./packages/server/lib/config.ts",
"./packages/server/lib/controllers/iframes.ts",
"./packages/server/lib/cypress.js",
"./packages/server/lib/environment.js",
"./packages/server/lib/errors.ts",
"./packages/server/lib/gui/windows.ts",
"./packages/server/lib/log.js",
"./packages/server/lib/makeDataContext.ts",
Expand Down Expand Up @@ -871,7 +872,6 @@
"./packages/server/lib/util/file-opener.ts",
"./packages/server/lib/util/fs.ts",
"./packages/server/lib/util/glob.js",
"./packages/server/lib/util/process_profiler.ts",
"./packages/server/lib/util/proxy.ts",
"./packages/server/lib/util/resourceTypeAndCredentialManager.ts",
"./packages/server/lib/util/socket_allowed.ts",
Expand Down
4 changes: 4 additions & 0 deletions tooling/v8-snapshot/src/setup/force-no-rewrite.ts
Expand Up @@ -58,6 +58,10 @@ export default [
'packages/server/lib/open_project.ts',
'packages/server/lib/project-base.ts',
'packages/server/lib/socket-ct.ts',
'packages/server/lib/browsers/utils.ts',
'packages/server/lib/cloud/exception.ts',
'packages/server/lib/errors.ts',
'packages/server/lib/util/process_profiler.ts',
'node_modules/prettier/index.js',
'node_modules/prettier/parser-babel.js',
'node_modules/prettier/parser-espree.js',
Expand Down

5 comments on commit 9b1d05d

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9b1d05d Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/11.1.0/linux-arm64/develop-9b1d05d5253e9ebc04ede59826576dca28ce4fbc/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9b1d05d Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/11.1.0/linux-x64/develop-9b1d05d5253e9ebc04ede59826576dca28ce4fbc/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9b1d05d Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/11.1.0/darwin-x64/develop-9b1d05d5253e9ebc04ede59826576dca28ce4fbc/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9b1d05d Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/11.1.0/darwin-arm64/develop-9b1d05d5253e9ebc04ede59826576dca28ce4fbc/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 9b1d05d Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/11.1.0/win32-x64/develop-9b1d05d5253e9ebc04ede59826576dca28ce4fbc/cypress.tgz

Please sign in to comment.