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 · 8 comments
Closed

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

bahmutov opened this issue Mar 29, 2019 · 8 comments

Comments

@bahmutov
Copy link
Collaborator

@bahmutov bahmutov 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
Copy link
Member

@jennifer-shehane jennifer-shehane commented Apr 1, 2019

Why though? 馃う鈥嶁檧锔

@bahmutov
Copy link
Collaborator Author

@bahmutov bahmutov commented Apr 1, 2019

@ithompson4
Copy link

@ithompson4 ithompson4 commented Apr 10, 2019

Can I try fixing this? Thanks.

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane 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
Copy link
Contributor

@ZWkang ZWkang 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
Copy link
Member

@jennifer-shehane jennifer-shehane 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
Copy link

@cypress-bot cypress-bot bot commented May 23, 2019

Released in 3.3.1.

@Nikh27091
Copy link

@Nikh27091 Nikh27091 commented Feb 16, 2021

I too had the same issue but it got resolved by writing the before function outside describe... example below

///
before(function () {
cy.fixture('example').then(function (data) {
this.data = data;
})
})

describe('TestSuite', function()
{
}

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants