diff --git a/packages/driver/src/cypress/cy.coffee b/packages/driver/src/cypress/cy.coffee index 4c549e924a9d..163780879f8b 100644 --- a/packages/driver/src/cypress/cy.coffee +++ b/packages/driver/src/cypress/cy.coffee @@ -458,10 +458,11 @@ create = (specWindow, Cypress, Cookies, state, config, log) -> ## if we have a prevSubject then error ## since we're invoking this improperly if prevSubject and ("optional" not in [].concat(prevSubject)) + stringifiedArg = $utils.stringifyActual(args[0]) $utils.throwErrByPath("miscellaneous.invoking_child_without_parent", { args: { cmd: name - args: $utils.stringifyActual(args[0]) + args: if _.isString(args[0]) then "\"#{stringifiedArg}\"" else stringifiedArg } }) diff --git a/packages/driver/test/cypress/integration/commands/aliasing_spec.coffee b/packages/driver/test/cypress/integration/commands/aliasing_spec.coffee index 9866e05398fe..59a28cfe3806 100644 --- a/packages/driver/test/cypress/integration/commands/aliasing_spec.coffee +++ b/packages/driver/test/cypress/integration/commands/aliasing_spec.coffee @@ -103,7 +103,7 @@ describe "src/cy/commands/aliasing", -> it "throws as a parent command", (done) -> cy.on "fail", (err) -> expect(err.message).to.include("before running a parent command") - expect(err.message).to.include("cy.as(foo)") + expect(err.message).to.include("cy.as(\"foo\")") done() cy.as("foo") diff --git a/packages/driver/test/cypress/integration/commands/connectors_spec.coffee b/packages/driver/test/cypress/integration/commands/connectors_spec.coffee index 2b2b20beb113..c646987ce2f0 100644 --- a/packages/driver/test/cypress/integration/commands/connectors_spec.coffee +++ b/packages/driver/test/cypress/integration/commands/connectors_spec.coffee @@ -526,7 +526,7 @@ describe "src/cy/commands/connectors", -> it "throws without a subject", (done) -> cy.on "fail", (err) -> - expect(err.message).to.include("cy.invoke(queue)") + expect(err.message).to.include("cy.invoke(\"queue\")") expect(err.message).to.include("child command before running a parent command") done() @@ -728,7 +728,7 @@ describe "src/cy/commands/connectors", -> it "throws without a subject", (done) -> cy.on "fail", (err) -> - expect(err.message).to.include("cy.its(wat)") + expect(err.message).to.include("cy.its(\"wat\")") expect(err.message).to.include("child command before running a parent command") done() diff --git a/packages/driver/test/cypress/integration/cypress/cy_spec.coffee b/packages/driver/test/cypress/integration/cypress/cy_spec.coffee index 5266969685d6..e4409b703d74 100644 --- a/packages/driver/test/cypress/integration/cypress/cy_spec.coffee +++ b/packages/driver/test/cypress/integration/cypress/cy_spec.coffee @@ -196,6 +196,15 @@ describe "driver/src/cypress/cy", -> cy.wrap("foo") cy.c() + it "fails when calling child command before parent with arguments", (done) -> + cy.on "fail", (err) -> + expect(err.message).to.include("Oops, it looks like you are trying to call a child command before running a parent command") + expect(err.message).to.include("cy.c(\"bar\")") + done() + + cy.wrap("foo") + cy.c("bar") + it "fails when previous subject becomes detached", (done) -> cy.$$("button:first").click -> $(@).remove() @@ -322,4 +331,4 @@ describe "driver/src/cypress/cy", -> it "updates state('current') with modified args", -> cy.get("form").eq(0).submit().then => - expect(cy.state("current").get("prev").get("args")[0].foo).to.equal("foo") \ No newline at end of file + expect(cy.state("current").get("prev").get("args")[0].foo).to.equal("foo")