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: show call count even if cy.stub().log(false). #18907

Merged
merged 3 commits into from Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/driver/src/cy/commands/agents.ts
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
@@ -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
@@ -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')
})
})