Skip to content

Commit

Permalink
fix(runner): fix run result attempts array order [develop] (#8303)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuceb committed Aug 18, 2020
1 parent 093f3e7 commit 6370f2e
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 19 deletions.
184 changes: 172 additions & 12 deletions packages/server/__snapshots__/5_spec_isolation_spec.js
Expand Up @@ -525,14 +525,15 @@ exports['e2e spec_isolation / failing with retries enabled'] = `
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (simple_failing_hook_spec.coffee) │
│ Searched: cypress/integration/simple_failing_hook_spec.coffee │
│ Specs: 2 found (simple_failing_hook_spec.coffee, simple_retrying_spec.js) │
│ Searched: cypress/integration/simple_failing_hook_spec.coffee, cypress/integration/simple_re │
│ trying_spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: simple_failing_hook_spec.coffee (1 of 1)
Running: simple_failing_hook_spec.coffee (1 of 2)
simple failing hook spec
Expand Down Expand Up @@ -620,6 +621,57 @@ Although you have test retries enabled, we do not retry tests when \`before all\
.mp4
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: simple_retrying_spec.js (2 of 2)
simple retrying spec
(Attempt 1 of 2) t1
1) t1
✓ t2
1 passing
1 failing
1) simple retrying spec
t1:
Error: t1 attempt #1
[stack trace lines]
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 2 │
│ Passing: 1 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 2 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: simple_retrying_spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
(Screenshots)
- /XXX/XXX/XXX/cypress/screenshots/simple_retrying_spec.js/simple retrying spec -- (1280x720)
t1 (failed).png
- /XXX/XXX/XXX/cypress/screenshots/simple_retrying_spec.js/simple retrying spec -- (1280x720)
t1 (failed) (attempt 2).png
(Video)
- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/simple_retrying_spec.js.mp4 (X second)
====================================================================================================
(Run Finished)
Expand All @@ -628,8 +680,10 @@ Although you have test retries enabled, we do not retry tests when \`before all\
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ simple_failing_hook_spec.coffee XX:XX 6 1 3 1 1 │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ✖ simple_retrying_spec.js XX:XX 2 1 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
1 of 1 failed (100%) XX:XX 6 1 3 1 1
2 of 2 failed (100%) XX:XX 8 2 4 1 1
`
Expand All @@ -638,10 +692,10 @@ exports['failing with retries enabled'] = {
"startedTestsAt": "2018-02-01T20:14:19.323Z",
"endedTestsAt": "2018-02-01T20:14:19.323Z",
"totalDuration": 5555,
"totalSuites": 5,
"totalTests": 6,
"totalFailed": 3,
"totalPassed": 1,
"totalSuites": 6,
"totalTests": 8,
"totalFailed": 4,
"totalPassed": 2,
"totalPending": 1,
"totalSkipped": 1,
"runs": [
Expand Down Expand Up @@ -706,7 +760,7 @@ exports['failing with retries enabled'] = {
"state": "failed",
"error": {
"name": "Error",
"message": "fail1\n\nBecause this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `beforeEach hooks`",
"message": "fail1",
"stack": "[stack trace lines]"
},
"videoTimestamp": 9999,
Expand All @@ -726,7 +780,7 @@ exports['failing with retries enabled'] = {
"state": "failed",
"error": {
"name": "Error",
"message": "fail1",
"message": "fail1\n\nBecause this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `beforeEach hooks`",
"stack": "[stack trace lines]"
},
"videoTimestamp": 9999,
Expand Down Expand Up @@ -778,7 +832,7 @@ exports['failing with retries enabled'] = {
"state": "failed",
"error": {
"name": "Error",
"message": "fail2\n\nBecause this error occurred during a `after each` hook we are skipping the remaining tests in the current suite: `afterEach hooks`",
"message": "fail2",
"stack": "[stack trace lines]"
},
"videoTimestamp": 9999,
Expand All @@ -798,7 +852,7 @@ exports['failing with retries enabled'] = {
"state": "failed",
"error": {
"name": "Error",
"message": "fail2",
"message": "fail2\n\nBecause this error occurred during a `after each` hook we are skipping the remaining tests in the current suite: `afterEach hooks`",
"stack": "[stack trace lines]"
},
"videoTimestamp": 9999,
Expand Down Expand Up @@ -898,6 +952,112 @@ exports['failing with retries enabled'] = {
"specType": "integration"
},
"shouldUploadVideo": true
},
{
"stats": {
"suites": 1,
"tests": 2,
"passes": 1,
"pending": 0,
"skipped": 0,
"failures": 1,
"duration": 1234,
"startedAt": "2018-02-01T20:14:19.323Z",
"endedAt": "2018-02-01T20:14:19.323Z"
},
"reporter": "spec",
"reporterStats": {
"suites": 1,
"tests": 2,
"passes": 1,
"pending": 0,
"failures": 1,
"start": "2018-02-01T20:14:19.323Z",
"end": "2018-02-01T20:14:19.323Z",
"duration": 1234
},
"hooks": [],
"tests": [
{
"title": [
"simple retrying spec",
"t1"
],
"state": "failed",
"body": "function () {\n var test = cy.state('test');\n throw new Error(\"\".concat(test.title, \" attempt #\").concat(cy.state('test').currentRetry()));\n }",
"displayError": "Error: t1 attempt #1\n [stack trace lines]",
"attempts": [
{
"state": "failed",
"error": {
"name": "Error",
"message": "t1 attempt #0",
"stack": "[stack trace lines]"
},
"videoTimestamp": 9999,
"duration": 1234,
"startedAt": "2018-02-01T20:14:19.323Z",
"screenshots": [
{
"name": null,
"takenAt": "2018-02-01T20:14:19.323Z",
"path": "/foo/bar/.projects/e2e/cypress/screenshots/simple_retrying_spec.js/simple retrying spec -- t1 (failed).png",
"height": 720,
"width": 1280
}
]
},
{
"state": "failed",
"error": {
"name": "Error",
"message": "t1 attempt #1",
"stack": "[stack trace lines]"
},
"videoTimestamp": 9999,
"duration": 1234,
"startedAt": "2018-02-01T20:14:19.323Z",
"screenshots": [
{
"name": null,
"takenAt": "2018-02-01T20:14:19.323Z",
"path": "/foo/bar/.projects/e2e/cypress/screenshots/simple_retrying_spec.js/simple retrying spec -- t1 (failed) (attempt 2).png",
"height": 720,
"width": 1280
}
]
}
]
},
{
"title": [
"simple retrying spec",
"t2"
],
"state": "passed",
"body": "function () {// pass\n }",
"displayError": null,
"attempts": [
{
"state": "passed",
"error": null,
"videoTimestamp": 9999,
"duration": 1234,
"startedAt": "2018-02-01T20:14:19.323Z",
"screenshots": []
}
]
}
],
"error": null,
"video": "/foo/bar/.projects/e2e/cypress/videos/simple_retrying_spec.js.mp4",
"spec": {
"name": "simple_retrying_spec.js",
"relative": "cypress/integration/simple_retrying_spec.js",
"absolute": "/foo/bar/.projects/e2e/cypress/integration/simple_retrying_spec.js",
"specType": "integration"
},
"shouldUploadVideo": true
}
],
"browserPath": "path/to/browser",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/reporter.js
Expand Up @@ -357,7 +357,7 @@ class Reporter {
state: orNull(test.state),
body: orNull(test.body),
displayError: orNull(test.err && test.err.stack),
attempts: _.map([test].concat(test.prevAttempts || []), (attempt) => {
attempts: _.map((test.prevAttempts || []).concat([test]), (attempt) => {
const err = attempt.err && {
name: attempt.err.name,
message: attempt.err.message,
Expand Down
12 changes: 6 additions & 6 deletions packages/server/test/e2e/5_spec_isolation_spec.js
Expand Up @@ -6,8 +6,8 @@ const fs = require('../../lib/util/fs')
const e2e = require('../support/helpers/e2e').default
const Fixtures = require('../support/helpers/fixtures')
const { expectCorrectModuleApiResult } = require('../support/helpers/resultsUtils')

const e2ePath = Fixtures.projectPath('e2e')
const it = e2e.it

const outputPath = path.join(e2ePath, 'output.json')

Expand All @@ -21,7 +21,7 @@ const specs = [
describe('e2e spec_isolation', () => {
e2e.setup()

e2e.it('fails', {
it('fails', {
spec: specs,
outputPath,
snapshot: false,
Expand All @@ -42,11 +42,11 @@ describe('e2e spec_isolation', () => {
},
})

e2e.it('failing with retries enabled', {
spec: 'simple_failing_hook_spec.coffee',
it('failing with retries enabled', {
spec: 'simple_failing_hook_spec.coffee,simple_retrying_spec.js',
outputPath,
snapshot: true,
expectedExitCode: 3,
expectedExitCode: 4,
config: {
retries: 1,
},
Expand All @@ -55,7 +55,7 @@ describe('e2e spec_isolation', () => {
const json = await fs.readJsonAsync(outputPath)

// also mutates into normalized obj ready for snapshot
expectCorrectModuleApiResult(json, { e2ePath, runs: 1 })
expectCorrectModuleApiResult(json, { e2ePath, runs: 2 })

snapshot('failing with retries enabled', json)
},
Expand Down
@@ -0,0 +1,11 @@
describe('simple retrying spec', () => {
it('t1', () => {
const test = cy.state('test')

throw new Error(`${test.title} attempt #${cy.state('test').currentRetry()}`)
})

it('t2', () => {
// pass
})
})

3 comments on commit 6370f2e

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6370f2e Aug 18, 2020

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.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/linux-x64/circle-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-425047/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/circle-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-425038/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6370f2e Aug 18, 2020

Choose a reason for hiding this comment

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

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-ia32/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6370f2e Aug 18, 2020

Choose a reason for hiding this comment

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

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

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.zip
npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/5.0.0/win32-x64/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.zip npm install https://cdn.cypress.io/beta/npm/5.0.0/appveyor-develop-6370f2ef4cfe1cde143b32ddcf1f343e7965125b-34714208/cypress.tgz

Please sign in to comment.