Skip to content

Commit

Permalink
fix: show call count even if cy.stub().log(false). (#18907)
Browse files Browse the repository at this point in the history
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
  • Loading branch information
sainthkh and emilyrohrbough committed Nov 19, 2021
1 parent 2a6ded2 commit 002fbdd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/driver/src/cy/commands/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ const onInvoke = function (Cypress, obj, args) {
const { agent } = obj
const agentName = agent._cyName

// bail if we've turned off logging this agent
if (agent._log === false) {
return
}

// fakes are children of the agent created with `withArgs`
const fakes = agent.matchingFakes(args)

Expand All @@ -59,6 +54,11 @@ const onInvoke = function (Cypress, obj, args) {
fake._cyLog.set('callCount', fake.callCount)
}

// bail if we've turned off logging this agent
if (agent._log === false) {
return
}

const logProps = {
name: agentName,
message: obj.message,
Expand Down
9 changes: 9 additions & 0 deletions packages/runner/cypress/fixtures/issues/issue-18042.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
it('test', () => {
const obj = {
foo () {},
}
const stub = cy.stub(obj, 'foo').log(false).as('foo')

obj.foo('foo', 'bar')
expect(stub).to.be.called
})
16 changes: 16 additions & 0 deletions packages/runner/cypress/integration/issues/issue-18042.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const helpers = require('../../support/helpers')

const { createCypress } = helpers
const { runIsolatedCypress } = createCypress()

// https://github.com/cypress-io/cypress/issues/18042
describe('issue 18042', () => {
beforeEach(function () {
return runIsolatedCypress(`cypress/fixtures/issues/issue-18042.js`)
})

it('Call count is shown even if cy.stub().log(false)', function () {
cy.contains('Spies / Stubs (1)').click()
cy.get('.call-count').eq(1).should('have.text', '1')
})
})

3 comments on commit 002fbdd

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 002fbdd Nov 19, 2021

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.0.1/circle-develop-002fbdda600aa83fce90dfa2d687bbf8aae6aa87/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 002fbdd Nov 19, 2021

Choose a reason for hiding this comment

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

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.0.1/appveyor-develop-002fbdda600aa83fce90dfa2d687bbf8aae6aa87/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 002fbdd Nov 19, 2021

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.0.1/circle-develop-002fbdda600aa83fce90dfa2d687bbf8aae6aa87/cypress.tgz

Please sign in to comment.