testing-library / cypress-testing-library

🐅 Simple and complete custom Cypress commands and utilities that encourage good testing practices.
http://npm.im/@testing-library/cypress
MIT License
1.8k stars 152 forks source link

Cypress test errors after upgraing to 9.0.0 and using testIsolation: false #248

Closed jazpearson closed 11 months ago

jazpearson commented 1 year ago

I'm not entirely sure how to report this will enough since i'm under NDA, but i was on the latest v8 and just upgraded to the latest (9.0.0). Cypress version is 12.1.0. Everything working as expected with v8, but i noticed v9 was out and supported Cypress v12, so thought i'd give it a go and i just wanted to report the issues in case it helps. I'm sorry that i can't give anything reproducible just yet, but if i get chance, i will.

This is a FANTASTIC library by the way.

Possibly an important point is that we are using { testIsolation: false } in our tests?

Relevant code or config

Examples that seem to be an issue have included these two commands. That doesn't mean that each time we call the commands they fail. It looks like they work ok in one test, but then in a following test (part of the same test suite) and not in isolation, the same call errors, as shown in the screenshot.

cy.findByRole('navigation', { name: /^(?!config-navigation|breadcrumb)/ });
cy.findbyrole('button', { name: 'add' }).click();

and our tests are scaffolded like this


description('testing feature a', { testIsolation: false }, () => {

   test('should do this', () => {

   });   

  test('should also do this', () => {

  });

});

What you did:

Upgraded to the latest version of the library

What happened:

image

Reproduction repository:

Problem description:

Suggested solution:

ddrakeatside commented 1 year ago

Also have same issue -- occurred after setting e2e.testIsolation to false.

image

NicholasBoll commented 1 year ago

Looking at the source code compared to the dist code, I don't see an immediate problem. My guess based on the error is the this keyword not being defined in a specific context. It passed tests, meaning the non-transformed code passed.

Is this error while running Chrome, Firefox, or Electron?

jazpearson commented 1 year ago

The error reported was originally in Chrome, but i tested in Firefox and Electron was able to reproduce there, too.

matt-vendia commented 1 year ago

I'm getting the same error - I patched the lib locally with the following change and no more errors:

// type: this.get('prev').get('chainerId') === this.get('chainerId') ? 'child' : 'parent',
type: this.get('prev') && this.get('prev').get('chainerId') === this.get('chainerId') ? 'child' : 'parent',
tgdevereux commented 1 year ago

I'm hitting this issue also, after upgrading to Cypress 12.3.0, and setting testIsolation to false (patching the lib locally like Matt suggested above in 'testing-library/cypress/dist/index.js:41:1' did address the error)

GiovaniBiagi commented 1 year ago

Having the same issues here! If anyone has a workaround that they can share, I'd appreciate it.

GiovaniBiagi commented 1 year ago

Updating, downgrading version to 8.0.0 solved my problem

solita-thaan commented 1 year ago

Also running into this same issue when upgrading to 9.0.0

JamyGolden commented 1 year ago

I'm busy adding "cypress/testing-library" to an existing project and I've run into this issue too. Things work fine inside a single it test function, but as soon as I have a second it, I get this error.

Using:

leonardobumbeers commented 11 months ago

It's been fixed on cypress-testing-library v10.0.1 :tada: https://github.com/testing-library/cypress-testing-library/releases/tag/v10.0.1

@jazpearson We can close this issue!