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

fix: browser-skipped tests are correctly recorded to the dashboard #24217

Merged
merged 34 commits into from
Oct 14, 2022

Conversation

emilyrohrbough
Copy link
Member

Ensure the test body and original test title is always recorded to the cloud, regardless of browser-skip state, to ensure the cloud does not incorrectly mark the test as "new" or "modified".

Test Steps:

Verified by recording to Staging & running system-tests/projects/e2e/record_config.cy.js using Edge & Chrome:

CYPRESS_INTERNAL_ENV=staging yarn cypress:run --dev --project ./system-tests/projects/e2e --spec ./system-tests/projects/e2e/cypress/e2e/config_record.cy.js --config projectId=ypt4pf --record --key <KEY> --browser <BROWSER>

Showing Issue:

  • First run w Edge - 2 ran, 2 pending - all correctly showing as first seen
  • Test Skip w Chrome - 1 ran, 2 pending, 1 pending due to browser - test body is missing so it was marked as modified & has modified tag
  • Adding Browser-specific Suite w/ Edge - 4 ran, 2 pending & 2 correctly showing as first seen
  • Suite Skip w Chrome - 1 ran, 2 pending, 3 pending due to browser - suite is skipped due to browser (note test is correct here due to partial fix) - all incorrectly marked as first seen because title path was incorrectly restored by the App and body is missing

Showing Fixes:

User facing changelog

Fixed as issue where browser-skipped tests were incorrectly recorded to the dashboardDashboard which resulted in the Dashboard marking the test as "new" or "modified" when it already existed. Fixes #23517.

How has the user experience changed?

Browser-skipped tests are correctly recorded to the dashboard.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [n/a] Has a PR for user-facing changes been opened in cypress-documentation?
  • [n/a] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 11, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Oct 11, 2022



Test summary

45913 0 4489 0Flakiness 8


Run details

Project cypress
Status Passed
Commit 58f6e92
Started Oct 12, 2022 9:57 PM
Ended Oct 12, 2022 10:14 PM
Duration 16:57 💡
OS Linux Debian - 11.4
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

runs.cy.ts Flakiness
1 App: Runs > Runs - Create Project > displays correct error message if the cloud mutation returns UNAUTHORIZED
commands/assertions.cy.js Flakiness
1 ... > has a pending state while retrying for commands with onFail
commands/xhr.cy.js Flakiness
1 ... > can alias a route without stubbing it
2 src/cy/commands/xhr > abort > aborts xhrs currently in flight
settings.cy.ts Flakiness
1 App: Settings > Cloud Settings > shows the Record Keys section
This comment includes only the first 5 flaky tests. See all 8 flaky tests in the Cypress Dashboard.

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

if (fnType === 'Test') {
// persist the original callback so we can send it to the cloud
// to prevent it from being registered as a modified test
runnable.body = testCallback.toString()
Copy link
Contributor

Choose a reason for hiding this comment

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

Since testCallback is always defined - either a function or a string (usually an empty string) - it looks like we could remove the if, and just always runnable.body = testCallback.toString(), regardless of fnType. Then we'd always have runnable.body defined, and the shape would be more consistent.

Or even better, set '' as a default argument, and skip the || ''s below in overloadMochaFnForConfig.

Copy link
Member Author

Choose a reason for hiding this comment

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

We only want to set on Test body for now.

function invokeFnWithOriginalTitle (ctx, originalTitle, mochaArgs, fn, _testConfig) {
const ret = fn.apply(ctx, mochaArgs)
type MochaArgs = [string, Function | undefined]
function createRunnable (ctx, fnType: 'Test' | 'Suite', mochaArgs: MochaArgs, runnableFn: Function, testCallback: Function | string, _testConfig?: Record<string, any>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we set a default value of _testConfig?: Record<string, any> = {}, then we'll always have one, and can remove the conditional around if (_testConfig) {} both here and later in this file.

In general I'm a fan of default values as a way of avoiding checking if a thing is defined - just make sure it always is, one way or another.

return $utils.reduceProps(runnable, RUNNABLE_PROPS)
}

const wrapAll = (runnable): any => {
// Reduce runnable down to its props and collections.
// Sent the the Reporter to populate command log
Copy link
Contributor

Choose a reason for hiding this comment

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

Sent by who? I'm not really sure what this comment is trying to tell me.

Edit: I think it makes more sense below where wrapAll is used, rather than up here where it's defined.

@@ -9,7 +9,7 @@ import $stackUtils, { StackAndCodeFrameIndex } from './stack_utils'
import $utils from './utils'
import type { HandlerType } from './runner'

const ERROR_PROPS = 'message type name stack parsedStack fileName lineNumber columnNumber host uncaught actual expected showDiff isPending docsUrl codeFrame'.split(' ')
const ERROR_PROPS = ['message', 'type', 'name', 'stack', 'parsedStack', 'fileName', 'lineNumber', 'columnNumber', 'host', 'uncaught', 'actual', 'expected', 'showDiff', 'isPending', 'docsUrl', 'codeFrame'] as const
Copy link
Member

Choose a reason for hiding this comment

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

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dashboard shows tests for review as modified when they are not modified
3 participants