Skip to content

Commit

Permalink
Addresses #2953 (#5174)
Browse files Browse the repository at this point in the history
* Addresses #2953

* Added proper test for new error message

* Didn't realize it ran this test as well, whoops

* Implementing changes as suggested by @jennifer-shehane

* Fixing tests and error output. Moved the checks to the start of the get command to ensure we always catch improper options

* Removing issue test since the querying spec covers it

* Using coffescript isArray check
  • Loading branch information
ryan-snyder authored and flotwig committed Sep 24, 2019
1 parent 41758d6 commit 1e698b5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/driver/src/cy/commands/querying.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ module.exports = (Commands, Cypress, cy, state, config) ->

get: (selector, options = {}) ->
ctx = @


if options is null or Array.isArray(options) or typeof options isnt 'object' then return $utils.throwErrByPath "get.invalid_options", {
args: { options }
}
_.defaults(options, {
retry: true
withinSubject: cy.state("withinSubject")
Expand All @@ -78,7 +81,6 @@ module.exports = (Commands, Cypress, cy, state, config) ->
})

consoleProps = {}

start = (aliasType) ->
return if options.log is false

Expand Down Expand Up @@ -467,4 +469,4 @@ module.exports = (Commands, Cypress, cy, state, config) ->
cy.state("withinSubject", null)

return subject
})
})
1 change: 1 addition & 0 deletions packages/driver/src/cypress/error_messages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ module.exports = {
get:
alias_invalid: "'{{prop}}' is not a valid alias property. Only 'numbers' or 'all' is permitted."
alias_zero: "'0' is not a valid alias property. Are you trying to ask for the first response? If so write @{{alias}}.1"
invalid_options: "#{cmd('get')} only accepts an options object for its second argument. You passed {{options}}"

getCookie:
invalid_argument: "#{cmd('getCookie')} must be passed a string argument for name."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,14 @@ describe "src/cy/commands/querying", ->
.server()
.route(/users/, {}).as("getUsers")
.get("@getUsers.all ")
_.each ["", "foo", [], 1, null ], (value) =>
it "throws when options property is not an object. Such as: #{value}", (done) ->
cy.on "fail", (err) ->
expect(err.message).to.include "only accepts an options object for its second argument. You passed #{value}"
done()

cy.get("foobar", value)

it "logs out $el when existing $el is found even on failure", (done) ->
button = cy.$$("#button").hide()

Expand Down

0 comments on commit 1e698b5

Please sign in to comment.