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: properly detect cy.intercept(url, routeMatcher, handler) overload #16167

Merged
merged 3 commits into from Apr 26, 2021

Conversation

flotwig
Copy link
Contributor

@flotwig flotwig commented Apr 23, 2021

User facing changelog

  • Fixed an issue in 7.0 where users could get a misleading "must pass a handler as the 3rd argument" error when using cy.intercept.
  • Improved types for cy.intercept().

Additional details

How has the user experience changed?

PR Tasks

  • [na] Have tests been added/updated?
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • [na] Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 23, 2021

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Apr 23, 2021



Test summary

9498 0 111 3Flakiness 0


Run details

Project cypress
Status Passed
Commit 7067c8e
Started Apr 23, 2021 4:57 PM
Ended Apr 23, 2021 5:09 PM
Duration 11:19 💡
OS Linux Debian - 10.8
Browser Multiple

View run in 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

@flotwig flotwig marked this pull request as ready for review April 23, 2021 17:15
@flotwig flotwig requested a review from a team as a code owner April 23, 2021 17:15
@flotwig flotwig requested review from jennifer-shehane and kuceb and removed request for a team April 23, 2021 17:15
} from './static-response-utils'
import { registerEvents } from './events'
import $errUtils from '../../cypress/error_utils'
import $utils from '../../cypress/utils'

const lowercaseFieldNames = (headers: { [fieldName: string]: any }) => _.mapKeys(headers, (v, k) => _.toLower(k))

export function hasOnlyRouteMatcherKeys (obj: any) {
return !_.isEmpty(obj) && !_.isArray(obj) && _.isEmpty(_.omit(obj, _.concat(PLAIN_FIELDS, STRING_MATCHER_FIELDS, DICT_STRING_MATCHER_FIELDS)))
Copy link
Contributor

Choose a reason for hiding this comment

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

will this be truthy if obj is a function?

Copy link
Contributor Author

@flotwig flotwig Apr 23, 2021

Choose a reason for hiding this comment

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

like this?

cy.intercept('/url', () => {})
cy.intercept('/url', function () {})

nope, see net_stubbing_spec for examples of such usage

@flotwig flotwig requested a review from kuceb April 23, 2021 19:59
Copy link
Contributor

@kuceb kuceb left a comment

Choose a reason for hiding this comment

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

great

@flotwig flotwig merged commit 338d702 into develop Apr 26, 2021
tgriesser added a commit that referenced this pull request Apr 26, 2021
* develop: (49 commits)
  fix: `cy.type()` should not change the value attr of button-like inputs. (#16154)
  fix: properly detect `cy.intercept(url, routeMatcher, handler)` overload (#16167)
  fix: consider multiple routes when looking for aliases (#16180)
  fix: pass contextIsolation: true (#16165)
  chore: fix failing "should handle aborted requests" test (#16170)
  feat(issue-3741): added keyboard support for folder (#15648)
  fix(webpack-dev-server): remove hard dependency on html-webpack-plugin v4  (#16108)
  chore(deps): downgrade electron to v12.0.0-beta.14 (#16113)
  fix: accept absolute paths in vite dev server (#16148)
  fix: cy.then shows wrong type when collection of HTMLElement's is provided (#15869)
  fix: do not treat utf8 requests as binary (#15946)
  chore: fix types
  docs: fix broken links for @cypress/react example recipes (#15674)
  update circle yml
  ignore undefined beforeEach
  fix: make vite-dev-server work on windows (#16103)
  chore: add triple slash reference
  chore: remove conflicting types
  chore: rebuild yarn lock
  resolve conflicts in master(fe0b63c) and develop
  ...
@flotwig flotwig deleted the intercept-fixes branch January 24, 2022 18:20
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.

Unexpected error when stubbing a request with cy.intercept(string, { headers: {} })
2 participants