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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash "Cannot read property 'error' of undefined" #3847

Closed
bahmutov opened this issue Mar 29, 2019 · 7 comments

Comments

4 participants
@bahmutov
Copy link
Collaborator

commented Mar 29, 2019

bug 馃悶

good

A test like this work fine - cannot find an element, times out

it.only('works', () => {
  cy.get('fff', { log: false }).type('foo')
})

Screen Shot 2019-03-29 at 11 15 38 AM

bad

But if I change the selector to be like this it crashes badly immediately (yes, I have just added backticks around 'foo' string

it.only('works', () => {
  cy.get(`'fff'`, { log: false }).type('foo')
})

Screen Shot 2019-03-29 at 11 16 32 AM

Seems the crash happens at the line options._log in

e.onFail = function() {
    return options._log.error(e);
}

Screen Shot 2019-03-29 at 11 16 52 AM

removing log: false

If I remove {log: false} from cy.get command the test correctly shows an error message

it.only('works', () => {
  cy.get(`'fff'`).type('foo')
})

Screen Shot 2019-03-29 at 11 18 43 AM

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Apr 1, 2019

Why though? 馃う鈥嶁檧锔

@bahmutov

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 1, 2019

@ithompson4

This comment has been minimized.

Copy link

commented Apr 10, 2019

Can I try fixing this? Thanks.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Apr 24, 2019

@ithompson4 yes we would love an open PR - even one that is a work in progress is fine. Check out our contributing doc and ask us if you get stuck.

@ZWkang

This comment has been minimized.

Copy link
Contributor

commented May 5, 2019

@jennifer-shehane
i saw the querying.coffee file.
here have some codes :

_.defaults(options, {
        retry: true
        withinSubject: cy.state("withinSubject")
        log: true
        command: null
        verify: true
      })

it allows you can pass a options.log to control options._log initialization

return if options.log is false
options._log ?= Cypress.log
          message: selector
          referencesAlias: if aliasObj?.alias then {name: aliasObj.alias}
          aliasType: aliasType
          consoleProps: -> consoleProps

the code looks like allow log: false to happen.

maybe just use options._log.error when options.log is true

when options.log is false just return error object

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented May 22, 2019

The code for this is done in #4127, but this has yet to be released. We'll update this issue and reference the changelog when it's released.

@cypress-bot

This comment has been minimized.

Copy link

commented May 23, 2019

Released in 3.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.