From 523e3dad73287914d62b001f9d5c0e9ef724d5c3 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Mon, 3 Dec 2018 14:31:45 -0500 Subject: [PATCH] Upgrade mocha to latest version (5.2.0) (#2703) Closes #2528 --- packages/driver/package.json | 2 +- packages/driver/src/cypress.coffee | 4 - packages/driver/src/cypress/cy.coffee | 12 +- .../driver/src/cypress/error_messages.coffee | 11 ++ packages/driver/src/cypress/mocha.coffee | 6 +- packages/driver/src/cypress/runner.coffee | 150 +++++++----------- .../integration/cypress/cypress_spec.coffee | 4 +- .../integration/e2e/promises_spec.coffee | 4 +- .../integration/e2e/return_value_spec.coffee | 24 +++ .../test/unit_old/cypress/mocha_spec.coffee | 16 -- .../test/unit_old/cypress/runner_spec.coffee | 25 --- .../1_commands_outside_of_test_spec.coffee.js | 2 + .../__snapshots__/3_only_spec.coffee.js | 45 +++++- .../4_return_value_spec.coffee.js | 36 +++-- packages/server/test/e2e/3_only_spec.coffee | 2 +- .../test/e2e/4_return_value_spec.coffee | 2 +- .../integration/only_multiple_spec.coffee | 13 ++ .../integration/return_value_spec.coffee | 6 +- 18 files changed, 200 insertions(+), 164 deletions(-) create mode 100644 packages/server/test/support/fixtures/projects/e2e/cypress/integration/only_multiple_spec.coffee diff --git a/packages/driver/package.json b/packages/driver/package.json index 40748a9cf55f..79aa42f3fcd0 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -49,7 +49,7 @@ "method-override": "3.0.0", "minimatch": "3.0.4", "minimist": "1.2.0", - "mocha": "cypress-io/mocha#58f6eac05e664fc6b69aa9fba70f1f6b5531a900", + "mocha": "5.2.0", "moment": "2.24.0", "morgan": "1.9.1", "npm-install-version": "6.0.2", diff --git a/packages/driver/src/cypress.coffee b/packages/driver/src/cypress.coffee index 411db0939b4c..c091e046685d 100644 --- a/packages/driver/src/cypress.coffee +++ b/packages/driver/src/cypress.coffee @@ -143,10 +143,6 @@ class $Cypress @action("cypress:config", config) initialize: ($autIframe) -> - ## push down the options - ## to the runner - @mocha.options(@runner) - @cy.initialize($autIframe) run: (fn) -> diff --git a/packages/driver/src/cypress/cy.coffee b/packages/driver/src/cypress/cy.coffee index 8a80eda2abee..2f6b7ad2d7d4 100644 --- a/packages/driver/src/cypress/cy.coffee +++ b/packages/driver/src/cypress/cy.coffee @@ -1054,9 +1054,15 @@ create = (specWindow, Cypress, Cookies, state, config, log) -> ## if we're cy or we've enqueued commands if isCy(ret) or (queue.length > currentLength) - ## the run should already be kicked off - ## by now and return this promise - return state("promise") + if fn.length + ## if user has passed done callback + ## don't return anything so we don't get an + ## 'overspecified' error from mocha + return + else + ## otherwise, return the 'queue promise' + ## so mocha awaits it + return state("promise") ## else just return ret return ret diff --git a/packages/driver/src/cypress/error_messages.coffee b/packages/driver/src/cypress/error_messages.coffee index 16d26dea288c..ce58cff24b9a 100644 --- a/packages/driver/src/cypress/error_messages.coffee +++ b/packages/driver/src/cypress/error_messages.coffee @@ -547,6 +547,17 @@ module.exports = { async_timed_out: "Timed out after '{{ms}}ms'. The done() callback was never invoked!" invalid_interface: "Invalid mocha interface '{{name}}'" timed_out: "Cypress command timeout of '{{ms}}ms' exceeded." + overspecified: """ + Cypress detected that you returned a promise in a test, but also invoked a done callback. Return a promise -or- invoke a done callback, not both. + + Read more here: https://on.cypress.io/returning-promise-and-invoking-done-callback + + #{divider(60, '-')} + + Original mocha error: + + {{error}} + """ navigation: cross_origin: """ diff --git a/packages/driver/src/cypress/mocha.coffee b/packages/driver/src/cypress/mocha.coffee index 21df770d7629..aabb7a210a0e 100644 --- a/packages/driver/src/cypress/mocha.coffee +++ b/packages/driver/src/cypress/mocha.coffee @@ -99,6 +99,9 @@ patchRunnerFail = -> ## matching the current Runner.prototype.fail except ## changing the logic for determing whether this is a valid err Runner::fail = (runnable, err) -> + if err?.message?.indexOf("Resolution method is overspecified") > -1 + err.message = $utils.errMessageByPath("mocha.overspecified", { error: err.stack }) + ## if this isnt a correct error object then just bail ## and call the original function if Object.prototype.toString.call(err) isnt "[object Error]" @@ -189,9 +192,6 @@ create = (specWindow, Cypress, reporter) -> getRootSuite: -> _mocha.suite - - options: (runner) -> - runner.options(_mocha.options) } module.exports = { diff --git a/packages/driver/src/cypress/runner.coffee b/packages/driver/src/cypress/runner.coffee index 15a96379d89c..d375c9f80a9a 100644 --- a/packages/driver/src/cypress/runner.coffee +++ b/packages/driver/src/cypress/runner.coffee @@ -6,7 +6,6 @@ Pending = require("mocha/lib/pending") $Log = require("./log") $utils = require("./utils") -defaultGrepRe = /.*/ mochaCtxKeysRe = /^(_runnable|test)$/ betweenQuotesRe = /\"(.+?)\"/ @@ -193,7 +192,7 @@ getAllSiblingTests = (suite, getTestById) -> ## iterate through each of our suites tests. ## this will iterate through all nested tests ## as well. and then we add it only if its - ## in our grepp'd tests array + ## in our filtered tests array if getTestById(test.id) tests.push test @@ -212,7 +211,7 @@ getTestFromHook = (hook, suite, getTestById) -> return found if found ## returns us the very first test - ## which is in our grepped tests array + ## which is in our filtered tests array ## based on walking down the current suite ## iterating through each test until it matches found = onFirstTest suite, (test) => @@ -227,11 +226,11 @@ getTestFromHook = (hook, suite, getTestById) -> ## we have to see if this is the last suite amongst ## its siblings. but first we have to filter out -## suites which dont have a grep'd test in them +## suites which dont have a filtered test in them isLastSuite = (suite, tests) -> return false if suite.root - ## grab all of the suites from our grep'd tests + ## grab all of the suites from our filtered tests ## including all of their ancestor suites! suites = _.reduce tests, (memo, test) -> while parent = test.parent @@ -296,17 +295,17 @@ overrideRunnerHook = (Cypress, _runner, getTestById, getTest, setTest, getTests) when "afterEach" t = getTest() - ## find all of the grep'd _tests which share + ## find all of the filtered _tests which share ## the same parent suite as our current _test tests = getAllSiblingTests(t.parent, getTestById) ## make sure this test isnt the last test overall but also - ## isnt the last test in our grep'd parent suite's tests array + ## isnt the last test in our filtered parent suite's tests array if @suite.root and (t isnt _.last(allTests)) and (t isnt _.last(tests)) changeFnToRunAfterHooks() when "afterAll" - ## find all of the grep'd allTests which share + ## find all of the filtered allTests which share ## the same parent suite as our current _test if t = getTest() siblings = getAllSiblingTests(t.parent, getTestById) @@ -327,17 +326,6 @@ overrideRunnerHook = (Cypress, _runner, getTestById, getTest, setTest, getTests) _runnerHook.call(@, name, fn) -matchesGrep = (runnable, grep) -> - ## we have optimized this iteration to the maximum. - ## we memoize the existential matchesGrep property - ## so we dont regex again needlessly when going - ## through tests which have already been set earlier - if (not runnable.matchesGrep?) or (not _.isEqual(runnable.grepRe, grep)) - runnable.grepRe = grep - runnable.matchesGrep = grep.test(runnable.fullTitle()) - - runnable.matchesGrep - getTestResults = (tests) -> _.map tests, (test) -> obj = _.pick(test, "id", "duration", "state") @@ -347,7 +335,12 @@ getTestResults = (tests) -> obj.state = "skipped" obj -normalizeAll = (suite, initialTests = {}, grep, setTestsById, setTests, onRunnable, onLogsById, getTestId) -> +hasOnly = (suite) -> + suite._onlyTests.length or + suite._onlySuites.length or + _.some(suite.suites, hasOnly) + +normalizeAll = (suite, initialTests = {}, setTestsById, setTests, onRunnable, onLogsById, getTestId) -> hasTests = false ## only loop until we find the first test @@ -361,10 +354,8 @@ normalizeAll = (suite, initialTests = {}, grep, setTestsById, setTests, onRunnab ## we hand back a normalized object but also ## create optimized lookups for the tests without ## traversing through it multiple times - tests = {} - grepIsDefault = _.isEqual(grep, defaultGrepRe) - - obj = normalize(suite, tests, initialTests, grep, grepIsDefault, onRunnable, onLogsById, getTestId) + tests = {} + normalizedSuite = normalize(suite, tests, initialTests, onRunnable, onLogsById, getTestId) if setTestsById ## use callback here to hand back @@ -375,10 +366,10 @@ normalizeAll = (suite, initialTests = {}, grep, setTestsById, setTests, onRunnab ## same pattern here setTests(_.values(tests)) - return obj + return normalizedSuite -normalize = (runnable, tests, initialTests, grep, grepIsDefault, onRunnable, onLogsById, getTestId) -> - normalizer = (runnable) => +normalize = (runnable, tests, initialTests, onRunnable, onLogsById, getTestId) -> + normalizeRunnable = (runnable) => runnable.id = getTestId() ## tests have a type of 'test' whereas suites do not have a type property @@ -402,57 +393,50 @@ normalize = (runnable, tests, initialTests, grep, grepIsDefault, onRunnable, onL push = (test) => tests[test.id] ?= test - obj = normalizer(runnable) + normalizedRunnable = normalizeRunnable(runnable) - ## if we have a default grep then avoid - ## grepping altogether and just push - ## tests into the array of tests - if grepIsDefault + if runnable.type isnt "suite" or not hasOnly(runnable) if runnable.type is "test" push(runnable) - ## and recursively iterate and normalize all other _runnables - _.each {tests: runnable.tests, suites: runnable.suites}, (_runnables, key) => - if runnable[key] - obj[key] = _.map _runnables, (runnable) => - normalize(runnable, tests, initialTests, grep, grepIsDefault, onRunnable, onLogsById, getTestId) - else - ## iterate through all tests and only push them in - ## if they match the current grep - obj.tests = _.reduce runnable.tests ? [], (memo, test) => - ## only push in the test if it matches - ## our grep - if matchesGrep(test, grep) - memo.push(normalizer(test)) - push(test) - memo - , [] - - ## and go through the suites - obj.suites = _.reduce runnable.suites ? [], (memo, suite) => - ## but only add them if a single nested test - ## actually matches the grep - any = anyTestInSuite suite, (test) => - matchesGrep(test, grep) - - if any - memo.push( - normalize( - suite, - tests, - initialTests, - grep, - grepIsDefault, - onRunnable, - onLogsById, - getTestId - ) - ) - - memo - , [] - - return obj + ## recursively iterate and normalize all other _runnables + _.each {tests: runnable.tests, suites: runnable.suites}, (_runnables, type) => + if runnable[type] + normalizedRunnable[type] = _.map _runnables, (runnable) => + normalize(runnable, tests, initialTests, onRunnable, onLogsById, getTestId) + + return normalizedRunnable + + ## this follows how mocha filters onlys. its runner#filterOnly + ## is pretty much the same minus the normalization part + filterOnly = (normalizedSuite, suite) -> + if suite._onlyTests.length + suite.tests = suite._onlyTests + normalizedSuite.tests = _.map suite._onlyTests, (test) => + normalizedTest = normalizeRunnable(test, initialTests, onRunnable, onLogsById, getTestId) + push(normalizedTest) + normalizedTest + suite.suites = [] + normalizedSuite.suites = [] + else + suite.tests = [] + normalizedSuite.tests = [] + _.each suite._onlySuites, (onlySuite) -> + normalizedOnlySuite = normalizeRunnable(onlySuite, initialTests, onRunnable, onLogsById, getTestId) + if hasOnly(onlySuite) + filterOnly(normalizedOnlySuite, onlySuite) + + suite.suites = _.filter suite.suites, (childSuite) -> + normalizedChildSuite = normalizeRunnable(childSuite, initialTests, onRunnable, onLogsById, getTestId) + suite._onlySuites.indexOf(childSuite) isnt -1 or filterOnly(normalizedChildSuite, childSuite) + normalizedSuite.suites = _.map suite.suites, (childSuite) -> + normalize(childSuite, tests, initialTests, onRunnable, onLogsById, getTestId) + + return suite.tests.length or suite.suites.length + + filterOnly(normalizedRunnable, runnable) + + return normalizedRunnable afterEachFailed = (Cypress, test, err) -> test.state = "failed" @@ -717,23 +701,6 @@ create = (specWindow, mocha, Cypress, cy) -> overrideRunnerHook(Cypress, _runner, getTestById, getTest, setTest, getTests) return { - grep: (re) -> - if arguments.length - _runner._grep = re - else - ## grab grep from the mocha _runner - ## or just set it to all in case - ## there is a mocha regression - _runner._grep ?= defaultGrepRe - - options: (options = {}) -> - ## TODO - ## need to handle - ## ignoreLeaks, asyncOnly, globals - - if re = options.grep - @grep(re) - normalizeAll: (tests) -> ## if we have an uncaught error then slice out ## all of the tests and suites and just generate @@ -750,7 +717,6 @@ create = (specWindow, mocha, Cypress, cy) -> normalizeAll( _runner.suite, tests, - @grep(), setTestsById, setTests, onRunnable, diff --git a/packages/driver/test/cypress/integration/cypress/cypress_spec.coffee b/packages/driver/test/cypress/integration/cypress/cypress_spec.coffee index e69ef13af196..0ea7e34f4980 100644 --- a/packages/driver/test/cypress/integration/cypress/cypress_spec.coffee +++ b/packages/driver/test/cypress/integration/cypress/cypress_spec.coffee @@ -29,7 +29,7 @@ describe "driver/src/cypress/index", -> expect($el.get(0)).to.eq($foo.get(0)) context "#backend", -> - it "sets __stackCleaned__ on errors", (done) -> + it "sets __stackCleaned__ on errors", -> cy.stub(@Cypress, "emit") .withArgs("backend:request") .yieldsAsync({ @@ -75,4 +75,4 @@ describe "driver/src/cypress/index", -> fn = -> Cypress.log({ message: 'My Log' }) - expect(fn).to.not.throw() \ No newline at end of file + expect(fn).to.not.throw() diff --git a/packages/driver/test/cypress/integration/e2e/promises_spec.coffee b/packages/driver/test/cypress/integration/e2e/promises_spec.coffee index cd165e95aec7..cbfcd7f286c9 100644 --- a/packages/driver/test/cypress/integration/e2e/promises_spec.coffee +++ b/packages/driver/test/cypress/integration/e2e/promises_spec.coffee @@ -106,7 +106,7 @@ describe "promises", -> cy.foo() - it "can return a promise that throws on its own without warning", (done) -> + it "can return a promise that throws on its own without warning", -> Cypress.Promise .delay(10) .then -> @@ -116,7 +116,6 @@ describe "promises", -> throw new Error("foo") .catch -> - done() it "can still fail cypress commands", (done) -> cy.on "fail", (err) -> @@ -128,3 +127,4 @@ describe "promises", -> .then -> cy.wrap({}).then -> throw new Error("foo") + return diff --git a/packages/driver/test/cypress/integration/e2e/return_value_spec.coffee b/packages/driver/test/cypress/integration/e2e/return_value_spec.coffee index 0eb158f95fad..8ef43f5ea33f 100644 --- a/packages/driver/test/cypress/integration/e2e/return_value_spec.coffee +++ b/packages/driver/test/cypress/integration/e2e/return_value_spec.coffee @@ -16,6 +16,10 @@ describe "return values", -> return undefined + it "can return cy and have done callback", (done) -> + cy.wrap({}).then -> + done() + it "throws when returning a non promise and invoking cy commands", (done) -> cy.on "fail", (err) -> expect(err.message).to.include("> foo") @@ -91,3 +95,23 @@ describe "return values", -> return "bar" cy.foo() + + describe "without invoking cy", -> + it "handles returning undefined", -> + return undefined + + it "handles synchronously invoking and returning done callback", (done) -> + return done() + + it "handles synchronously invoking done callback and returning undefined", (done) -> + done() + return undefined + + it "handles synchronously invoking done callback and returning a value", (done) -> + done() + return "foo" + + it "handles asynchronously invoking done callback", (done) -> + setTimeout -> + done() + return "foo" diff --git a/packages/driver/test/unit_old/cypress/mocha_spec.coffee b/packages/driver/test/unit_old/cypress/mocha_spec.coffee index 73c02d9ccea8..77507fb9b914 100644 --- a/packages/driver/test/unit_old/cypress/mocha_spec.coffee +++ b/packages/driver/test/unit_old/cypress/mocha_spec.coffee @@ -51,12 +51,6 @@ describe "$Cypress.Mocha API", -> beforeEach -> @mocha = $Cypress.Mocha.create(@Cypress, @iframe) - describe "abort", -> - it "resets mocha grep to all", -> - @mocha.grep /\w+/ - @Cypress.trigger "abort" - expect(@mocha.mocha._grep).to.match /.*/ - describe "stop", -> it "calls stop", -> stop = @sandbox.stub @mocha, "stop" @@ -104,16 +98,6 @@ describe "$Cypress.Mocha API", -> @Cypress.trigger("stop") expect(@Cypress.mocha).to.be.null - context "#grep", -> - beforeEach -> - @mocha = $Cypress.Mocha.create(@Cypress, @iframe) - - it "proxies argument to mocha.grep", -> - grep = @sandbox.spy @mocha.mocha, "grep" - re = /\w+/ - @mocha.grep(re) - expect(grep).to.be.calledWith re - context "#getRunner", -> beforeEach -> @mocha = $Cypress.Mocha.create(@Cypress, @iframe) diff --git a/packages/driver/test/unit_old/cypress/runner_spec.coffee b/packages/driver/test/unit_old/cypress/runner_spec.coffee index 3ed987f861dc..9d60c67e4900 100644 --- a/packages/driver/test/unit_old/cypress/runner_spec.coffee +++ b/packages/driver/test/unit_old/cypress/runner_spec.coffee @@ -626,20 +626,6 @@ describe "$Cypress.Runner API", -> expect(calls).to.have.length(1) done() - context "#grep", -> - beforeEach -> - @runner = $Cypress.Runner.runner(@Cypress, {}) - - it "set /.*/ by default", -> - @runner.grep() - expect(@runner.runner._grep).to.match /.*/ - - it "can set to another RegExp", -> - re = /.+/ - @runner.grep(re) - - expect(@runner.runner._grep).to.eq re - context "#anyTestInSuite", -> beforeEach -> runner = Fixtures.createRunnables { @@ -717,17 +703,6 @@ describe "$Cypress.Runner API", -> ## 4 tests expect(@runner.tests).to.have.length(4) - it "only pushes matching grep tests", -> - ## with 4 existing tests - expect(@runner.tests).to.have.length(4) - - @runner.grep(/four/) - - @runner.normalizeAll() - - ## only 1 test should have matched the grep - expect(@runner.tests).to.have.length(1) - it "sets runnable type", -> types = _.map @runner.runnables, "type" expect(types).to.deep.eq ["suite", "test", "suite", "test", "test", "suite", "test"] diff --git a/packages/server/__snapshots__/1_commands_outside_of_test_spec.coffee.js b/packages/server/__snapshots__/1_commands_outside_of_test_spec.coffee.js index fc2b212b5de3..7297c207df95 100644 --- a/packages/server/__snapshots__/1_commands_outside_of_test_spec.coffee.js +++ b/packages/server/__snapshots__/1_commands_outside_of_test_spec.coffee.js @@ -47,6 +47,8 @@ We dynamically generated a new test to display this failure. at stack trace line at stack trace line at stack trace line + at stack trace line + at stack trace line diff --git a/packages/server/__snapshots__/3_only_spec.coffee.js b/packages/server/__snapshots__/3_only_spec.coffee.js index 07f47cef3995..ad6cc66aad3c 100644 --- a/packages/server/__snapshots__/3_only_spec.coffee.js +++ b/packages/server/__snapshots__/3_only_spec.coffee.js @@ -7,14 +7,49 @@ exports['e2e only spec failing 1'] = ` ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Cypress: 1.2.3 │ │ Browser: FooBrowser 88 │ - │ Specs: 1 found (only_spec.coffee) │ - │ Searched: cypress/integration/only_spec.coffee │ + │ Specs: 2 found (only_multiple_spec.coffee, only_spec.coffee) │ + │ Searched: cypress/integration/only*.coffee │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ ──────────────────────────────────────────────────────────────────────────────────────────────────── - Running: only_spec.coffee... (1 of 1) + Running: only_multiple_spec.coffee... (1 of 2) + + + s1 + ✓ t3 + - t4 + + + 1 passing + 1 pending + + + (Results) + + ┌─────────────────────────────────────────┐ + │ Tests: 2 │ + │ Passing: 1 │ + │ Failing: 0 │ + │ Pending: 1 │ + │ Skipped: 0 │ + │ Screenshots: 0 │ + │ Video: true │ + │ Duration: X seconds │ + │ Spec Ran: only_multiple_spec.coffee │ + └─────────────────────────────────────────┘ + + + (Video) + + - Started processing: Compressing to 32 CRF + - Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) + + +──────────────────────────────────────────────────────────────────────────────────────────────────── + + Running: only_spec.coffee... (2 of 2) s1 @@ -52,9 +87,11 @@ exports['e2e only spec failing 1'] = ` Spec Tests Passing Failing Pending Skipped ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ + │ ✔ only_multiple_spec.coffee XX:XX 2 1 - 1 - │ + ├────────────────────────────────────────────────────────────────────────────────────────────────┤ │ ✔ only_spec.coffee XX:XX 1 1 - - - │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ - All specs passed! XX:XX 1 1 - - - + All specs passed! XX:XX 3 2 - 1 - ` diff --git a/packages/server/__snapshots__/4_return_value_spec.coffee.js b/packages/server/__snapshots__/4_return_value_spec.coffee.js index 9db8da1481dd..aeb6fa32c8d8 100644 --- a/packages/server/__snapshots__/4_return_value_spec.coffee.js +++ b/packages/server/__snapshots__/4_return_value_spec.coffee.js @@ -18,10 +18,11 @@ exports['e2e return value failing1 1'] = ` 1) errors when invoking commands and return a different value - 2) errors when invoking commands in custom command and returning differnet value + 2) errors when invoking commands in custom command and returning different value + 3) errors when not invoking commands, invoking done callback, and returning a promise 0 passing - 2 failing + 3 failing 1) errors when invoking commands and return a different value: CypressError: Cypress detected that you invoked one or more cy commands but returned a different value. @@ -54,7 +55,7 @@ https://on.cypress.io/returning-value-and-commands-in-test at stack trace line at stack trace line - 2) errors when invoking commands in custom command and returning differnet value: + 2) errors when invoking commands in custom command and returning different value: CypressError: Cypress detected that you invoked one or more cy commands in a custom command but returned a different value. The custom command was: @@ -85,18 +86,34 @@ https://on.cypress.io/returning-value-and-commands-in-custom-command at stack trace line at stack trace line + 3) errors when not invoking commands, invoking done callback, and returning a promise: + Cypress detected that you returned a promise in a test, but also invoked a done callback. Return a promise -or- invoke a done callback, not both. + +Read more here: https://on.cypress.io/returning-promise-and-invoking-done-callback + +----------------------------------------------------------- + +Original mocha error: + +Error: Resolution method is overspecified. Specify a callback *or* return a Promise; not both. + at stack trace line + at stack trace line + Error: Resolution method is overspecified. Specify a callback *or* return a Promise; not both. + at stack trace line + at stack trace line + (Results) ┌────────────────────────────────────────┐ - │ Tests: 2 │ + │ Tests: 3 │ │ Passing: 0 │ - │ Failing: 2 │ + │ Failing: 3 │ │ Pending: 0 │ │ Skipped: 0 │ - │ Screenshots: 2 │ + │ Screenshots: 3 │ │ Video: true │ │ Duration: X seconds │ │ Spec Ran: return_value_spec.coffee │ @@ -106,7 +123,8 @@ https://on.cypress.io/returning-value-and-commands-in-custom-command (Screenshots) - /foo/bar/.projects/e2e/cypress/screenshots/return_value_spec.coffee/errors when invoking commands and return a different value (failed).png (1280x720) - - /foo/bar/.projects/e2e/cypress/screenshots/return_value_spec.coffee/errors when invoking commands in custom command and returning differnet value (failed).png (1280x720) + - /foo/bar/.projects/e2e/cypress/screenshots/return_value_spec.coffee/errors when invoking commands in custom command and returning different value (failed).png (1280x720) + - /foo/bar/.projects/e2e/cypress/screenshots/return_value_spec.coffee/errors when not invoking commands invoking done callback and returning a promise (failed).png (1280x720) (Video) @@ -122,9 +140,9 @@ https://on.cypress.io/returning-value-and-commands-in-custom-command Spec Tests Passing Failing Pending Skipped ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ ✖ return_value_spec.coffee XX:XX 2 - 2 - - │ + │ ✖ return_value_spec.coffee XX:XX 3 - 3 - - │ └────────────────────────────────────────────────────────────────────────────────────────────────┘ - 1 of 1 failed (100%) XX:XX 2 - 2 - - + 1 of 1 failed (100%) XX:XX 3 - 3 - - ` diff --git a/packages/server/test/e2e/3_only_spec.coffee b/packages/server/test/e2e/3_only_spec.coffee index 3540916e29f1..42542b1326fc 100644 --- a/packages/server/test/e2e/3_only_spec.coffee +++ b/packages/server/test/e2e/3_only_spec.coffee @@ -5,7 +5,7 @@ describe "e2e only spec", -> it "failing", -> e2e.exec(@, { - spec: "only_spec.coffee" + spec: "only*.coffee" snapshot: true expectedExitCode: 0 }) diff --git a/packages/server/test/e2e/4_return_value_spec.coffee b/packages/server/test/e2e/4_return_value_spec.coffee index c5c811d47d46..4cfa52092d1a 100644 --- a/packages/server/test/e2e/4_return_value_spec.coffee +++ b/packages/server/test/e2e/4_return_value_spec.coffee @@ -7,5 +7,5 @@ describe "e2e return value", -> e2e.exec(@, { spec: "return_value_spec.coffee" snapshot: true - expectedExitCode: 2 + expectedExitCode: 3 }) diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/only_multiple_spec.coffee b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/only_multiple_spec.coffee new file mode 100644 index 000000000000..84271b37ff0c --- /dev/null +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/only_multiple_spec.coffee @@ -0,0 +1,13 @@ +it "t1", -> +it "t2", -> +it "t3", -> + +describe "s1", -> + it.only "t3", -> + + it.only "t4" + + it "t5", -> + +describe "s2", -> + it "t3", -> diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/return_value_spec.coffee b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/return_value_spec.coffee index 1190c7f9a8ec..ca32aaed8db8 100644 --- a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/return_value_spec.coffee +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/return_value_spec.coffee @@ -3,10 +3,14 @@ it "errors when invoking commands and return a different value", -> return [{}, 1, 2, "foo", (->)] -it "errors when invoking commands in custom command and returning differnet value", -> +it "errors when invoking commands in custom command and returning different value", -> Cypress.Commands.add "foo", -> cy.wrap(null) return "bar" cy.foo() + +it "errors when not invoking commands, invoking done callback, and returning a promise", (done) -> + return Promise.resolve(null).then -> + done()